search
HomeBackend DevelopmentPHP Tutorial用php+mysql一个名片库程序_php基础

用php+mysql一个名片库程序,有分类查找,分页功能。

第一步:按下列代表先做个静态页面。


          
              
              
            
              
              
            
          
  
                
                    
                    
                  
                    
                    
                    
                    
                  
                
输入关键字:

                    
  
                      
                      按姓名
  
                      
                      按地区
  
                      
                      按职位

              
  
                
                
              

        

第二步:如下建库。
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 $keyword;?>



        
  




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{
    $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) {
print "下一页 ";
}
print "
";
//显示全部留言
//print "全部名片 ";
print "
";
print "
";
?>
若有问题请mailto:lyjrich@sina.com,这个程序有个问题如果要显示全部名片的话,我这个程序还没有实现此功能,如果你知道在这个程序里怎样显示全部名片的话希望能发mail给我。  

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    
Statement
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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),