|
-
Jun 16th, 2002, 11:20 AM
#1
Thread Starter
PowerPoster
Limiting number of records to display
My mySQL database table has around 200+ tables and it's doing this weird flashy thing as the page is being generated. I don't know if that's because my code is terrible or if it's just too many records to display on one page.
How can I limit the number of records to, say, 25 per page and have back and next buttons generated?
-
Jun 16th, 2002, 01:48 PM
#2
Stuck in the 80s
Use "LIMIT" in your SQL query. "SELECT * From table LIMIT 5, 50" Which means (unless I have the 5 and 50 backwards) "Show only 5 records starting at 50."
-
Jun 16th, 2002, 01:51 PM
#3
Thread Starter
PowerPoster
will that automatically display next and back buttons or just display 5 records and I have to figure out the rest?
-
Jun 16th, 2002, 03:30 PM
#4
Stuck in the 80s
You're going to have to figure it out, but it's not that hard.
Number of pages needed = ceil(mysql_num_rows() / 5)
Then just keep track of the current page and the starting number.
-
Jun 16th, 2002, 03:33 PM
#5
Stuck in the 80s
You're going to have to do it yourself, but it's not that hard.
Just keep track of the current page. You can get the total number of needed page by doing:
PHP Code:
ceil(mysql_num_rows($something)) / 5;
I'm sure there's examples of it somewhere.
-
Jun 16th, 2002, 04:22 PM
#6
Originally posted by The Hobo
Use "LIMIT" in your SQL query. "SELECT * From table LIMIT 5, 50" Which means (unless I have the 5 and 50 backwards) "Show only 5 records starting at 50."
heh you have it backwards.
select * from table LIMIT 5,10; # Retrieve rows 6-15
LIMIT (offset,) (rows)
-
Jun 16th, 2002, 05:34 PM
#7
Stuck in the 80s
bah, I figured as much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|