Home > Backend Development > PHP Tutorial > my life would suck without you A business card library program using php+mysql

my life would suck without you A business card library program using php+mysql

WBOY
Release: 2016-07-29 08:34:33
Original
942 people have browsed it

Use php+mysql to create a business card library program with classification search and paging functions.
Step one: Make a static page first according to the following representation.


                                                                                                     0 "class =" p10 "& gt;
& lt; tr & gt;
& lt; td colorpan =" 2 "head =" 79 "& gt;
& lt; table width =" 280 "border =" 0 "0" CELLSPACING = "0" Cel. lpadding ="0" class="p10">
                                                                                                                                                                               class="c3a">
                                                                                                                                                            By name ;
                                                                                                                                                                                input type="radio" name="inout" value="A">
                                                                            
  
                                                                                                                                            
                                                               Step: Create a database as follows.
id  int(4)    否    auto_increment   
http  varchar(25)    否
name  varchar(50)    否       
email  varchar(50)    否       
gs  varchar(200)    否       
address  varchar(200)    否        
yb  varchar(20)    否       
zw  varchar(100)    否       
tel  varchar(20)    否       
fax  varchar(20)    否       
bp  varchar(20)    否       
第三步:查找执行程序
if (!isset($show)) $show=0;
{
if($query1=="查找")
{
$db=mysql_connect("localhost","用户名","密码");
$dbname=mysql_select_db("库文件名",$db);
mysql_query('select * from 表文件名',$db);
$limit=2; //一页显示几条内容。
//global $query,$queryyy,$quer;
switch($inout)
{
case "N":
//按姓名查找
$query="select * from card where name like '%$keyword%'";

$queryyy = "select * from card where name like '%$keyword%' order by id desc limit $show, $limit";
break;
case "C":
//按地区查找
$query="select * from card where address like '%$keyword%' order by id desc";
$queryyy = "select * from card where address like '%$keyword%' order by id desc limit $show, $limit";
break;
case "A":
// 按职务查找
$query="select * from card where zw like '%$keyword%' order by id desc";
$queryyy = "select * from card where zw like '%$keyword%' order by id desc limit $show, $limit";
break;
}
$result1=mysql_query($query);
$total=mysql_num_rows($result1); //总的符合条件的记录数
$quer=mysql_query($queryyy,$db);
$pages=ceil($total/$limit);
}
}
?>
  

你查找的关键字是::


        
echo "
  
    
    
  

      
查找名片如下: 共有[";
      echo $total;
       echo "
]张名片

    

      
共分[";
      echo $pages;
     echo "
]页

    
";
while ($row = mysql_fetch_array($quer))
{
echo "    

    
  
  

      
          
          
        
          
          
        
          
          
        
      
  
            
$row[gs]

          
  
     $row[name] $row[zw]

              

              

          
  
            

                  
  • 电话:$row[tel]

  •               
  • 传真:$row[fax]

  •               
  • 网址:$row[http]

  •               
  • 电子信箱:$row[eamil]

  •               
  • 地址:$row[address]

  •               
  • 邮编:$row[yb]

  •               
  • BP:$row[bp]

  •             

          

    

";
        
}
$vor = $show + $limit;
$back = $show - $limit;
print "
";
print "";
print "
";
for ($i=1;$i<=$pages;$i++)
{
    $new_offset=$limit*($i-1);
    $parameter="query1=$query1&keyword=$keyword&inout=$inout";
     
     
    print " $i$nbsp";
}
print "
";
//显示上一页
if ($show - $limit >= 0)
{
print " 上一页";
}
print "
";
//显示下一页
if (($show + $limit) < $total)
{
print "下一页 ";
}
print "
";
//Show all messages
//print " All business cards ";
print "
";
print "
";
?>
If you have any questions, please mailto: lyjrich@sina.com, there is a problem with this program. If you want to display all business cards, my program has not implemented this function. If you know how to display all business cards in this program, I hope you can send me an email.
[The copyright of this article is jointly owned by the author and Aosuo.com. If you need to reprint, please indicate the author and source]

The above introduces my life would suck without you, a business card library program using php+mysql, including the content of my life would suck without you. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template