With Php+mysql a business card library program, there are classification search, paging function.
First step: Make a static page by following the representative.
Step Two: Build the library 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 three: Find the execution program
if (!isset ($show)) $show = 0;
{
if ($query 1== "Find")
{
$db =mysql_connect ("localhost", "username", "password");
$dbname =mysql_select_db ("Library file name", $db);
mysql_query (' SELECT * from table filename ', $db);
$limit = 2; A page shows a few things.
Global $query, $queryyy, $quer;
Switch ($inout)
{
Case "N":
Find by name
$query = "SELECT * from card where name like '% $keyword% '";
$queryyy = "SELECT * from card where name as '% $keyword% ' ORDER BY id desc limit $show, $limit";
Break
Case "C":
Find 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 "A":
Find by Job title
$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
}
$result 1=mysql_query ($query);
$total =mysql_num_rows ($result 1); Total number of records that meet the criteria
$quer =mysql_query ($queryyy, $db);
$pages =ceil ($total/$limit);
}
}
?>
The keywords you are looking for are:
echo "
Find business cards as follows: Total ["; Echo $total; echo "] Card
|
A total of ["; Echo $pages; echo "] Page
|
";
while ($row = Mysql_fetch_array ($quer))
{
echo "
$row [GS] |
$row [name] $row [ZW] /b> |
- Tel: $row [Tel]
- Fax: $row [fax]
- URL: $row [http]
- e-mail: $row [eamil]
- addresses: $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= $query 1&keyword= $keyword &inout= $inout";
Print " $i$nbsp"; } Print " |
"; Show Previous Page if ($show-$limit >= 0) { Print "Previous page"; } Print " |
"; Show Next Page if (($show + $limit) < $total) { Print "Next page"; } Print " |
"; Show 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 show all the cards, I have not implemented this program, if you know how to display all the business card in this program, I hope to send mail to me.
"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"
The above describes my life would suck without you with php+mysql a business card library program, including my life would suck the content of you, I hope to be interested in PHP tutorial friends helpful.