Jump to content

LIMIT


manix

Recommended Posts

I'm creating a simple pagination where it's supposed to show me 10 records per page from the database and in order to do that I'm using the LIMIT function but it's not working right

 

It's working for the fist page tho, here's the code:

 

// FIRST PAGE

$query = "SELECT id, header, story, datetime, author, reported, comments FROM stories WHERE `type`='1' ORDER BY id DESC";
$result = mysql_query($query." LIMIT 0,10");
while($row = mysql_fetch_assoc($result))
{ ... 

 

$pages=2; // just for temp testing
for ($i=1; $i<=$pages; $i++){
$result = mysql_query($query." LIMIT ".($i*10).",".($i*10+10));
while($row = mysql_fetch_assoc($result))
{

 

and it's working but it's showing me 12 or 13 or even more records on the second page ... why ?

 

omg I just checked the syntax and realized what input 2 is ... >.< sorry for the spam

Link to comment
https://forums.phpfreaks.com/topic/242259-limit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.