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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
terji
Forum Commoner
Posts: 37
Joined: Tue May 14, 2002 5:27 pm
Location: Denmark

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

Post 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?
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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");
Post Reply