Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.