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.
<Form method = "post" action = "find1.php" name = "card" onSubmit = "return card_Validator (this)">
<Table width = "400" border = "0" cellspacing = "0" cellpadding = "0" class = "p10">
<Tr>
<Td colspan = "2" height = "79">
<Table width = "280" border = "0" cellspacing = "0" cellpadding = "0" class = "p10">
<Tr>
<Td colspan = "3" height = "37"> enter the Keyword:
<Input type = "text" name = "keyword" class = "c3a">
</Td>
</Tr>
<Tr>
<Td>
<Input type = "radio" name = "inout" value = "N" checked>
By name </td>
<Td>
<Input type = "radio" name = "inout" value = "C">
By region </td>
<Td>
<Input type = "radio" name = "inout" value = "A">
By position </td>
</Tr>
</Table>
</Td>
</Tr>
<Tr>
<Td colspan = "2" height = "47">
<Input type = "submit" name = "query1" value = "">
<Input type = "reset" name = "Submit2" value = "clear">
</Td>
</Tr>
</Table>
</Form>
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
<? Php
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 );
}
}
?>
<P> <font color = "# FF0000" face = "" size = "3"> <strong> <span style = "font-size: 12pt "> <font size =" 4 "color =" #000000 "> the keywords you search for are: </font> </span> </strong> </font>: <font color = red> <? Echo $ keyword;?> </Font> </p>
<?
Echo "<table width = '000000' border = '0' cellspacing = '0' cellpadding = '0' align = 'center'>
<Tr>
<Td width = '000000'>
<Div align = 'center'> search for business cards as follows: [<font color = red> ";
Echo $ total;
Echo "</font>] A business card </div>
</Td>
<Td width = '86'>
<Div align = 'right'> [<font color = red> ";
Echo $ pages;
Echo "</font>] page </div>
</Td>
</Tr>
</Table> ";
While ($ row = mysql_fetch_array ($ quer ))
{
Echo "<table width = '000000' border = '1' cellspacing = '0' cellpadding = '0' height = '000000' align = 'center' bordercolordark = '# eeeeee' bordercolorlight = '#666666'>
<Tr>
<Td>
<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0' align = 'center' bgcolor = '# eeeeee'>
<Tr>
<Td colspan = '2' height = '53'>
<Div align = 'center' class = 'pp13'> <font color = '#000000'> $ row [gs] </font> </div>
</Td>
</Tr>
<Tr>
<Td height = '35' colspan = '2' align = center>
<B class = 'pp13'> $ row [name] <span class = 'pp9'> $ row [zw] <br>
</Span> </B>
<Hr color = '# FFCC00 'noshade size = '1'>
</Td>
</Tr>
<Tr>
<Td colspan = '2'>
<Ul>
<Li> <span class = 'pp10'> tel: $ row [tel] </span> </li>
<Li> <span class = 'pp10'> fax: $ row [fax] </span> </li>
<Li> <span class = 'pp10'> URL: $ row [http] </span> </li>
<Li> <span class = 'pp10'> email address: $ row [eamil] </span> </li>
<Li> <span class = 'pp10'> address: $ row [address] </span> </li>
<Li> <span class = 'pp10'> zip code: $ row [yb] </span> </li>
<Li> <span class = 'pp10'> BP: $ row [bp] </span> </li>
</Ul>
</Td>
</Tr>
</Table>
</Td>
</Tr>
</Table> <br> ";
}
$ Vor = $ show + $ limit;
$ Back = $ show-$ limit;
Print "<center> ";
Print "<table width =" 455 "border =" 0 "bordercolor =" # FFCC33 "cellspacing =" 0 "align =" center "> ";
Print "<tr height =" 20 "bgcolor =" # FFD6AC "> <td width =" 350 "> ";
For ($ I = 1; $ I <= $ pages; $ I ++)
{
$ New_offset = $ limit * ($ i-1 );
$ Parameter = "query1 = $ query1 & keyword = $ keyword & inout = $ inout ";
Print "<a href =" $ PHP_SELF? Show = $ I & $ parameter "> <B> $ I </B> </a> $ nbsp ";
}
Print "</td> <td width =" 45 "> ";
// Display the previous page
If ($ show-$ limit> = 0)
{
Print "<a href =" $ PHP_SELF? Show = $ back & $ parameter "> previous page </a> ";
}
Print "</td> <td width =" 45 "> ";
// Display the next page
If ($ show + $ limit) <$ total)
{
Print "<a href =" $ PHP_SELF? Show = $ vor & $ parameter "> next page </a> ";
}
Print "</td> <td width =" 60 "> ";
// Display all messages
// Print "<a href =" $ PHP_SELF? Show = all. & $ parameter "> all business cards </a> ";
Print "</td> </tr> </table> ";
Print "</center> ";
?>
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]