View Full Version : php - Breaking Pages of Data
Goodlookinguy
2008-11-03, 05:41 PM
e-FUCKING-RASED : Damn it, I shouldn't let other people use my accounts. I know php damn it.
WetWired
2008-11-03, 11:09 PM
There is a limit clause to SQL queries that you can use if you're worried about efficiency. Obviously, you can use a count query to get the total number without the overhead of actually retreiving all of them.
Goodlookinguy
2008-11-04, 08:43 PM
There is a limit clause to SQL queries that you can use if you're worried about efficiency. Obviously, you can use a count query to get the total number without the overhead of actually retrieving all of them.
I know all about the LIMIT clause, but I've had a rather hard time coming up with a method of breaking them up properly.
I believe it's a for statement I'm trying to do, but I'm failing to figure it out. Maybe, I can try to look at existing data and keep breaking it up from there. Hmm...maybe. Wait, no, I don't have it. AH!
WetWired
2008-11-04, 09:02 PM
get the count of total results
number of pages=intval((total+perpage-1)/perpage)
check that requested page is >0 and <=number of pages
query the results LIMIT perpage*(pagenum-1),perpage
post results
display pagenav with pages 1 to number of pages
vBulletin® v3.8.2, Copyright ©2000-2025, Jelsoft Enterprises Ltd.