Here is the script for the search that do the work and the form.htm (look below)
If this could help!... if you need more let me know!
<?php
//recherche
include 'db.php';
// Define the number of results per page
$max_results = 2;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
switch($critere)
{
case "email address":
$requete = "SELECT FROM lesgens WHERE email_address LIKE '%$choix%' ORDER BY email_address LIMIT $from, $max_results".$ordre;
break;
case "first name":
$requete = "SELECT FROM lesgens WHERE first_name LIKE '%$choix%' ORDER BY first_name ".$ordre;
break;
case "last name":
$requete = "SELECT FROM lesgens WHERE last_name LIKE '%$choix%' ORDER BY last_name ".$ordre;
break;
case "username":
$requete = "SELECT FROM lesgens WHERE username LIKE '%$choix%' ORDER BY username ".$ordre;
break;
}
//envoi de la requête
echo ($requete);
$id_result = mysql_query ($requete,$connection);
if(!$id_result){ echo "Lecture impossible, erreur N°",mysql_errno(),mysql_error();}
//
if(!isset($GET['page'])){
$page = 1;
} else {
$page = $GET['page'];
}
// Perform MySQL query on only the current page number's results
$camarche =
$sql = mysql_query("SELECT FROM lesgens LIMIT $from, $max_results");
//lecture du nombre de lignes du résultat
$nblignes= mysql_num_rows($id_result);
echo " <h2 align=\"center\" > Résultat : Il y a $nblignes membres dans la
sélection </h2>";
//affichage des résultats sous forme de tableau HTML
while($tablivres = mysql_fetch_array($id_result,MYSQL_ASSOC))
{
echo "<table width=\"700\" border=\"1\">";
echo" <tr>" ;
echo" <td align=\"center\" width=\"30%\" > ";
echo "<img src=\"$tablivres[photo]\" ></td> ";
echo"<td width=\"70%\" height=\"195\" rowspan=\"2\"> <h2>{$tablivres[email_address]}</h2> <br/><b>{$tablivres[first_name]}</b><br/>Collection :
{$tablivres[last_name]} <br/>Paru le: {$tablivres[username]} <br/>Code isbn: {$tablivres[url]} </td>";
echo"</tr>";
echo"</table><br/>";
}
// Figure out the total number of results in DB:
//$total_results = mysql_result(mysql_query("SELECT COUNT() as Num FROM lesgens"),0);
echo ">Nombre de résultats: "."$nblignes ";
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($nblignes / $max_results);
// Build Page Number Hyperlinks
echo "<center>Choisir votre page<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Suivants>></a>";
}
echo "</center>";
mysql_close($connection);
?>
</body>
Here is the form.htm
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center"></div>
<h3 align="center"> Recherche:</h3>
<form method="post" action="script/recherche.php3">
<table width="400" border="1" align="center" cellpadding="0" cellspacing="0">
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Rechercher : </b></td>
<td width="55%"> <input type="text" name="choix" maxlength="30"
size="30"> </td>
</tr>
<tr bordercolor="#CCCCCC">
<td width="45%"><b>Critère de recherche</b>
<td width="55%"> <select name="critere" size="1">
<option>email address</option>
<option>first name</option>
<option>last name</option>
<option>username</option>
</select> </td>
</tr>
<tr>
<td width="45%"><b>Afficher par ordre:</b></td>
<td width="55%">Croissant
<input type="radio" name="ordre" value="ASC">
décroissant
<input type="radio" name="ordre" value="DESC"> </td>
</tr>
<tr>
<td width="45%"> <div align="center">
<input type="reset" name="reset"
value="Effacer">
</div></td>
<td width="55%"> <div align="center">
<input type="submit" name="submit2"
value="Envoyer">
</div></td>
</tr>
</table>
<div align="center"></div>
</form>
<p> </p>
</body>