Return to Snippet

Revision: 4296
at November 23, 2007 05:51 by andyhartleeds


Initial Code
$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?>">&lt; 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 &gt;</a></p>
        <?php
	}

Initial URL

                                

Initial Description

                                

Initial Title
Next and Previous links/limiting results

Initial Tags

                                

Initial Language
PHP