Use php + mysql as a business card Library Program

Source: Internet
Author: User
A business card library program using php + MySQL has the function of searching by category and querying by page. Step 1: Create a static page as follows. & Lt; formmethod & quot; post & quot; action & quot; find1.php & quot; name & quot; card & quot; onSubmit & quot; returncard_Validator (this) A business card library program using php + MySQL has the function of searching by category and querying by page.

Step 1: Create a static page as follows.

Step 2: create a database as follows.
Id int (4) no auto_increment
Http varchar (25) No
Name varchar (50) No
Email varchar (50) No
Gs varchar (200) No
Address varchar (200) No
Yb varchar (20) No
Zw varchar (100) No
Tel varchar (20) No
Fax varchar (20) No
Bp varchar (20) No

Step 3: Find the execution program

If (! Isset ($ show) $ show = 0;

{




If ($ query1 = "search ")

{

$ Db = mysql_connect ("localhost", "username", "password ");
$ Dbname = mysql_select_db ("database file name", $ db );
Mysql_query ('select * from table filename ', $ db );
$ Limit = 2; // several items are displayed on one page.

// Global $ query, $ queryyy, $ quer;
Switch ($ inout)

{
 
Case "N ":
// Search by name
$ 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 ":
// Search by region
$ 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 "":
// Search by position
$ 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); // The total number of qualified records

$ Quer = mysql_query ($ queryyy, $ db );
$ Pages = ceil ($ total/$ limit );
}
}

?>
 
 

The keyword you are searching for is::


          
    




Echo"




         

   

Search for business cards [";
Echo $ total;
Echo "] a business card


  

   

Divided [";
Echo $ pages;
   
Echo "] page


  
";

While ($ row = mysql_fetch_array ($ quer ))
{

Echo"




          

   









                                                      
 
      

$ Row [gs]


     
 
   $ Row [name] $ row [zw]

       

       
    
     
 
      

           
  • Tel: $ row [tel]

  •        
  • Fax: $ row [fax]

  •        
  • URL: $ row [http]

  •        
  • Email: $ row [eamil]

  •        
  • Address: $ row [address]

  •        
  • Zip code: $ 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"
";
// Display the previous page
If ($ show-$ limit> = 0)
{
Print "previous page ";
}
Print"
";
// Display the next page
If ($ show + $ limit) <$ total)
{
Print "next page ";
}
Print"
";
// Display all messages
// Print "all business cards ";
Print"
";
Print" ";
?>
If there is a problem please mailto: lyjrich@sina.com, this program has a problem if you want to display all business cards, I this program has not implemented this function, if you know how to display all the business cards in this program, you may want to mail it to me.

[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.