Page 1 of 1

Showing 10 results at a time from my recordset...

Posted: Thu Aug 15, 2002 5:18 pm
by terji
I'm using a MySQL database and can't figure out how to show only 10 results from my query at a time?!?!?!?
<<previous 10 | next 10>>
I've been messing around with this query:

Code: Select all

SELECT * FROM table LIMIT 0, 10
But how to I browse without persistently storing 0 and 10?

Posted: Thu Aug 15, 2002 6:39 pm
by fatalcure

Posted: Thu Aug 15, 2002 6:54 pm
by hob_goblin
i usually do something like this:

Code: Select all

$pid = $_GET&#1111;'pid']; // GRAB THE PAGE ID FROM GET
if(empty($pid) || $pid < 1)&#123;
$pid = 1;
&#125; // CHECK THAT ITS REALLY A PAGE

$num = 10; // NUMBER PER PAGE
$end = $pid * $num;
$beg = $end - $num;

$qry = mysql_query("SELECT * FROM table LIMIT $beg, $end");