query pages
Posted: Wed May 03, 2006 12:47 pm
well ive recently been making a 'page' system on my thing, basicialy works like this:
this worked fine but I wanted it ordered differently, it was displaying the older ones first so I changed the query to:
which works fine on the first page but the second page it starts with the last added when it should be the first...
Code: Select all
<?PHP
//pages.php?page=2
$page = ereg_replace('[^0-9]', '', $_GET['page']); //get page number
$page *= 10; //multiple by 10 to get result id's correct
$result = mysql_query("SELECT name FROM search WHERE id>='$page' LIMIT 10");
echo '<hr>';
while($row=mysql_fetch_assoc($result)) {
echo $row['name'];
echo '<hr>';
}?>Code: Select all
SELECT name FROM search WHERE id>='$start' ORDER by id DESC LIMIT 10