Select Number of records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gld4x4
Forum Newbie
Posts: 8
Joined: Wed Feb 18, 2004 6:31 am

Select Number of records

Post by gld4x4 »

I have a database with 500 records in it, I want to select all but only display 20 at time, then the next 20 and so forth. Can any body give a little advice? I know the basics , select * from data etc...

Thanks
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

look into the LIMIT clause and also read some pagination tutorials
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Hmm, I'm not sure this can be done in a single MySQL query. I'd probably do it by making numerous calls from PHP, with each query limiting from 0 to 20, 21 to 40, 41 to 60, and so on.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Depending on how you are displying them, you could just get them all, array them, then display the array 20 lines at a time
Post Reply