Jump to content

retrieve the last N element of the database


Ordinary_Shepp
Go to solution Solved by Psycho,

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. 

Edited by Ordinary_Shepp
Link to comment
Share on other sites

  • Solution

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"

Link to comment
Share on other sites

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

Edited by Psycho
Link to comment
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.