Hello,
I have a question about adding paging to my database results. I would like to add the functionality to restrict my database results to 10 or 15 rows per page. I am simply returning database rows as one table per row currently.
Suggestions appreciated.
Thanks,
ReportsNerd
Adding Paging to Database Results
Moderator: General Moderators
-
ReportsNerd
- Forum Newbie
- Posts: 4
- Joined: Thu Jul 29, 2010 7:13 am
Re: Adding Paging to Database Results
The term you want to google is paginating. you can find lots of tutorials on it. as well as alot of theads about it here.
basically what you want to do is limit your database results based on an offset
so say you want 20 results per page... your offset would start at 0 because you want the first 20 results. then you would limit to 20 as you dont want to display more than 20.
page one would use the LIMIT in your sql statement as [text]LIMIT 0, 20[/text]
page 2 would be [text]LIMIT 20,20[/text]
page 3 would be [text]LIMIT 30,20[/text]
see the pattern?
hope this helps... googling will give you much clearer answers.
basically what you want to do is limit your database results based on an offset
so say you want 20 results per page... your offset would start at 0 because you want the first 20 results. then you would limit to 20 as you dont want to display more than 20.
page one would use the LIMIT in your sql statement as [text]LIMIT 0, 20[/text]
page 2 would be [text]LIMIT 20,20[/text]
page 3 would be [text]LIMIT 30,20[/text]
see the pattern?
hope this helps... googling will give you much clearer answers.