Jump to content

retrieve the last N element of the database


Ordinary_Shepp

Recommended Posts

Hello, I am doing a project where I need to store a large volume of data in a table. So, I can't show all the data at a time. And performing a query for all those data may be time consuming. So I want to implement a view system where I can show data step by step. Say I want to show last 50 data at a time. So, It seems that I need to traverse through the rows with two button. "Previous" and "Next" . What could be the query for this purpose or how I can do it? I am using mysql and php.

I am not expecting a bunch of code. But I will appreciate your comment with necessary functions for php and query ideas or examples for mysql and viewing procedure for HTML. 

What you are referring to is called pagination. How you achieve this requires more than just a query (you need two queries plus PHP code to manage it). There are tons of tutorials on how to accomplish this. There used to be one on this site, but it looks like they've removed them all. :(

 

Just Google "PHP pagination tutorial"

Sure thing. Post back if you run into any problems/questions after reviewing a tutorial or two.

 

EDIT:When I clicked the Tutorials tab on this site, it is empty of content. But, when I just did a Google search, the PHP Freaks tutorial was the second result and can be accessed here: http://www.phpfreaks.com/tutorial/basic-pagination

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.