Jump to content

Display query results only 25 at a time?


Recommended Posts

Hey all.


I have a query that selects data from a datbase based on a criteria.  Easy enough.  But now I am growing and the amount displaying is too much.


How can you, via php, have a queries result be displayed only so many at a time and auto create links that show the rest?  Like if query returns 82 results, I want it to display 25 immediately and create 3 links at the bottom.  The next link would show 26-50.  The next 51-75.  And the final 76-82.  etc



$result = mysql_query("SELECT * FROM pay");
$num_rows = mysql_num_rows($result);

while($row = mysql_fetch_array($result))
echo $row['first_name'];
echo $row['last_name'];
echo $row['item_name'];
echo $row['option_selection1'];
echo $row['payment_date'];
echo $row['stat'];


This is simple.  But what happens when the results are 125?  I want to limit it to displaying 25 at a time.


Is the only way to manually create seperate pages and have each one show 1-25, then 26-50, etc?


Or is there a way to have the script do it, itself?  Any tutorials out there on this specifically?  Hopefully I am making sense.



Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

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

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.