Use Php+mysql a Business card library program
Last Update:2017-02-28
Source: Internet
Author: User
With Php+mysql a business card library program, there is a category lookup, paging function.
The first step: The following representatives to do a static page first.
<form method= "POST" action= "find1.php" name= "card" >
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "class=" P10 ">
<tr>
<TD colspan= "2" height= ">"
<table width= "280" border= "0" cellspacing= "0" cellpadding= "0" class= "P10" >
<tr>
<TD colspan= "3" height= "Notoginseng" > Input keywords:
<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= ">"
<input type= "Submit" Name= "Query1" value= "Find" >
<input type= "reset" name= "Submit2" value= "clear" >
</td>
</tr>
</table>
</form>
The second step: 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 an executing program
<?php
if (!isset ($show)) $show = 0;
{
if ($query 1== "Find")
{
$db =mysql_connect ("localhost", "username", "password");
$dbname =mysql_select_db ("library filename", $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 like '% $keyword% ' ORDER BY id desc limit $show, $limit";
Break
Case "C":
Find by Region
$query = "SELECT * from Card where", "$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 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 eligible records
$quer =mysql_query ($queryyy, $db);
$pages =ceil ($total/$limit);
}
}
?>
<p><font color= "#FF0000" face= "Song Body" size= "3" ><strong><span style= "font-size:12pt" ><font Size= "4" color= "#000000" > The keyword you are looking for is: </font></span></strong></font>:<font color=red ><? Echo $keyword;? ></font></p>
?
echo "<table width= ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' align= ' center ' >
<tr>
Width= ' <TD ' >
<div align= ' center ' > Find business cards are as follows: A total of [<font color=red>];
Echo $total;
echo "</FONT>] Card </div>
</td>
Width= ' <TD ' >
<div align= ' right ' > are divided into [<font color=red> ";
Echo $pages;
echo "</font>] page </div>
</td>
</tr>
</table> ";
while ($row = Mysql_fetch_array ($quer))
{
echo "<table width= ' 440 ' border= ' 1 ' cellspacing= ' 0 ' cellpadding= ' 0 ' height= ' 175 ' align= '" Center ' bordercolordark= ' Eeeeee ' bordercolorlight= ' #666666 ' >
<tr>
<td>
<table width= ' 380 ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' align= ' center ' bgcolor= ' #eeeeee ' >
<tr>
<TD colspan= ' 2 ' height= ' >
<div align= ' center ' class= ' pp13 ' ><font color= ' #000000 ' > $row [gs]</font></div>
</td>
</tr>
<tr>
<TD height= ' colspan= ' 2 ' align=center>
<b class= ' pp13 ' > $row [name] <span class= ' pp9 ' > $row [ZW] <br>
</span></b>
</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 ' > website: $row [http]</span></li>
<li><span class= ' pp10 ' > email: $row [eamil]</span></li>
<li><span class= ' PP10 ' > Address: $row [address]</span></li>
<li><span class= ' pp10 ' > Zip: $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=" "bgcolor=" #FFD6AC "><td width=" ">";
for ($i =1; $i <= $pages; $i + +)
{
$new _offset= $limit * ($i-1);
$parameter = "query1= $query 1&keyword= $keyword &inout= $inout";
Print "<a href=" $PHP _self?show= $i & $parameter "><b> $i </b></a> $nbsp";
}
Print "</td><td width=" ">";
Show Previous Page
if ($show-$limit >= 0)
{
Print "<a href=" $PHP _self?show= $back & $parameter "> Prev </a>";
}
Print "</td><td width=" ">";
Show Next Page
if (($show + $limit) < $total)
{
Print "<a href=" $PHP _self?show= $vor & $parameter "> Next </a>";
}
Print "</td><td width=" ">";
Show All messages
Print "<a href=" $PHP _self?show=all.& $parameter "> All business cards </a>";
print "</td></tr></table>";
print "</center>";
?>
If you have any questions please mailto:lyjrich@sina.com, this program has a problem if you want to show all the business cards, I This program has not implemented this function, if you know how to display all business cards in this program, I hope to send mail to me.