Click to view older...

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
wibblywobbly
Forum Newbie
Posts: 17
Joined: Mon Oct 19, 2009 10:11 am

Click to view older...

Post 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!
User avatar
JAY6390
Forum Newbie
Posts: 20
Joined: Sat Apr 17, 2010 6:51 am
Location: UK

Re: Click to view older...

Post 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
Post Reply