Pagination d'une requête
Posté : 23 mai 2007, 06:51
Voici j'essais tant bien que mal de fair eun système de pagination (très simple) pour ma requête. J'Y ARRIVE PAS
Quelqu'un pourrais m'orienter unpeu.
Voici le code de ma requête. !!
Merci
Quelqu'un pourrais m'orienter unpeu.
Voici le code de ma requête. !!
if(isset($_POST['rechercher'])) // POST RECHERCHER
{
$afficher1 = 1;
$showimg = "oui";
$showinfo = "oui";
$order = "code";
$keywords = $_POST["recherche"];
$sql = "SELECT description.code, description.nom, description.nomfr, description.genre, description.description, description.video, loan.loanto, loan.date_out, loan.attente
FROM loan RIGHT JOIN description
ON description.code=loan.code
WHERE description.code LIKE '%".$keywords."%' OR
description.nom LIKE '%".$keywords."%' OR
description.nomfr LIKE '%".$keywords."%' OR
loan.loanto LIKE '%".$keywords."%'
ORDER BY ".$order."";
$resultat = mysql_query($sql);
} // IF RECHERCHER
else {}
if($afficher1 == 1)
{ ?>
<tr class="onglet">
<td class="dvd-image"></td>
<td class="dvd-code">CODE</td>
<td class="dvd-titre">TITRE</td>
<td class="dvd-genre">GENRE</td>
<td class="dvd-loan">LOUER À</td>
</tr>
<?
}
if (mysql_num_rows($resultat) >= 1)
while ($rows=mysql_fetch_array($resultat))
{
?>
<tr class="resultat">
<td class="image"> <? if ($showimg=="oui")
{
$image = (file_exists("thumb/".$rows['code'] ."_t.jpg")) ? "thumb/".$rows['code'] ."_t.jpg" : "thumb/defaut.jpg";
$b_image = (file_exists("thumb_b/b_".$rows['code'] .".jpg")) ? "thumb_b/b_".$rows['code'] .".jpg" : "thumb/defaut.jpg";?>
<A HREF="#" onClick="window.open('<? echo $b_image; ?>','_blank',' width=410, height=500');return(false)"><?echo('<img src="'.$image.'" border="0" >');?></a>
<? }?>
</td>
<td class="code"><? echo $rows['code']; ?></td>
<td class="titre"><b><a href="infodvd.php?code=<? echo $rows['code']; ?>"><? echo $rows['nom']; if ($rows['video']== true){?><a href="infodvd.php?code=<? echo $rows['code']; ?>#video"><img src="images/video.jpg" border="0" height="20"></a><?}?><br><div class="description"><b><? echo $rows['nomfr']; ?></b></div></a></b>
<? if ($showinfo=="oui")
{ ?>
<div class="description"><? echo $rows['description']; ?></div>
<? } ?>
</td>
<td class="genre"><? echo $rows['genre']; ?></td>
<td class="loan"><? if ($rows['loanto']==false)
{ echo '<img src="images/yes.jpg" border="0" width="18" height="16"> <br>Disponible</a>'; }
elseif ($rows['loanto']== 'En Attente')
{ echo '<img src="images/no.png" border="0"> <br>En attente</a>'; }
elseif ($rows['loanto']==true)
{ echo '<img src="images/no.png" border="0"> <br>Non Disponible</a>'; }
?></td>
</tr>
<? }
if($afficher2 == 1){ ?><form action="search.php" method="post">
<tr><td colspan="5" align="center"><input type="submit" name="prochain" value="Voir les 10 prochains"></td></tr>
</form><?
}
else if (mysql_num_rows($resultat) <= 1)
{
if (isset($_POST['alpha']))
{
echo ("<tr><td colspan='5' class='aucune_donnee'>Aucun résultat <br>pour un DVD commancant<br>par la lettre <font color='#CC0000'>$alphabet</font></font></td></tr>");
}
else if (isset($_POST['rechercher']))
{
echo ("<tr><td colspan='5' class='aucune_donnee'>Aucun résultat <br>pour un DVD contenant<br>le mot <font color='#CC0000'>$keywords</font></font></td></tr>");
}
}
?>
</table>
Sinon connessez-vous une adresse qui l'explique très bien !!!Merci