latest post to the front page in php

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
tat
Forum Newbie
Posts: 11
Joined: Mon Feb 02, 2009 10:56 am

latest post to the front page in php

Post by tat »

Guys,

Any idea how I could code in php so that the latest 10 posts make it to the index page?
Any guidance will be appreciated.

Thanks
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: latest post to the front page in php

Post by mattpointblank »

SELECT * FROM posts ORDER BY postID DESC LIMIT 10
tat
Forum Newbie
Posts: 11
Joined: Mon Feb 02, 2009 10:56 am

Re: latest post to the front page in php

Post by tat »

wow that easy? I just need a query? thanks a lot
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: latest post to the front page in php

Post by mattpointblank »

Well, you'll have to then loop through the results using mysql_fetch_array and do something with them, and obviously adapt the query to fit your database structure. But yeah, in principle it's simple.
Post Reply