Page 1 of 1

Click to view older...

Posted: Sat Apr 17, 2010 7:33 am
by wibblywobbly
Hello,

This might belong in the theory section of the forum. I'm looking for some general advice. If I have many entries in a database, let's say that they are all blog entries, how do I display only 5 at a time?

I'd like to have the latest 5 blog entires on the home page with a button saying "click for older entries" - when you press it then you're given entries 6 - 10, then you can click for the next 5 and so on. Basically I don't want the viewer to be dismayed by a thousand blog entries all at once.

Presumably this is something to do with using GET and posting numbers in the address bar? But in general, what's the theory on how to do this?

Your advice would be greatly appreciated!

Many thanks!

Re: Click to view older...

Posted: Sat Apr 17, 2010 9:40 am
by JAY6390
You do this with pagination (check out my pagination class link in my signature). To just show five entries, you would use LIMIT 5 at the end of your query

Code: Select all

SELECT * FROM `blog_table` ORDER by `blog_date` DESC LIMIT 5