/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$sort_by = ($_GET["sort_by"]) ? $_GET["sort_by"] : "created"; $sort_order = ($_GET["sort_order"]) ? $_GET["sort_order"] : "DESC"; $opposite_sort_order = ($sort_order == "ASC") ? "DESC" : "ASC"; $start = ($_GET["start"]) ? $_GET["start"] : 0; $results_limit = 10; ... $total_results = mysql_num_rows($result); $query .= "ORDER BY " . $sort_by . " " . $sort_order . " LIMIT " . $start . ", " . $results_limit . ";"; ... if ($start > 0) { ?> <p style="float: left;"><a href="?sort_by=<?=$sort_by?>&sort_order=<?=$sort_order?>&start=<?=$start - $results_limit?>">< Previous</a></p> <?php } if (($start + $results_limit) < $total_results) { ?> <p style="float: right;"><a href="?sort_by=<?=$sort_by?>&sort_order=<?=$sort_order?>&start=<?=$start + $results_limit?>">Next ></a></p> <?php }