1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| / Defines query
$select = "SELECT * FROM objects
WHERE name LIKE '%".$recherche."%'
OR description LIKE '%".$recherche."%'
OR country LIKE '%".$recherche."%'
ORDER BY name ASC LIMIT ".$limit.",".$results_pg;
// Runs query
$result = mysql_query($select, $connect) or die ("Erreur : ".mysql_error());
// Counts total records in query
$row = mysql_num_rows($result);
$totalRows = $row[0];
// Recalculates $limit to know if other results to display
$nextLimit = $limit + $results_pg;
$prevLimit = $limit - $results_pg;
// Displays link to previous page if necessary
if($limit != 0) {
echo '<a href="'.$pgName.'?limit='.$prevLimit.'"><< Page précédente</a>';
}
// Displays link to next page if necessary
if($nextLimit < $totalRows) {
echo '<a href="'.$pgName.'?limit='.$nextLimit.'">Page Suivante >></a>';
}
?> |
Partager