Jump to content

Display query results only 25 at a time?


NETSYNC

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

 

Example:

$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.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/216535-display-query-results-only-25-at-a-time/
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.