Jump to content

PHP Forum help?


lalnfl

Recommended Posts

Okay I am making a forum and it is almost finished. The only thing is, I am stuck on how to get the most updated topics to appear at the top of the list. Like on every forum there is a new forum post that you havent visited yet. They are at the top of the list. How would I do that???

Link to comment
Share on other sites

Do you have a field storing a timestamp for when a thread's last post was?

 

If so you could just use an ORDER BY clause like this simplified example:

SELECT threadname, author FROM threads WHERE board_id=2 ORDER BY last_post DESC

 

The DESC makes it sort backwards (higher to lower instead of visa-versa). Since a more recent timestamp will be larger, the query results will be ordered by post time from newest to oldest, at which point you can loop and display as normal and they will be sorted.

 

If you don't have a "last post" type field associated with your thread and only store the timestamp with the post itself you could probably do something involving a join but joins hurt my brain and I've been doing way too much repetitive work today to provide you with a clear example of that.

Link to comment
Share on other sites

But I do have another question though! I want the forum to say the forum topic then right next to the forum topic I want it to say "new". Like it does here on the phpfreaks.com forums. Like if the user hasn't viewed it yet, it would say "new". How would I do something like that? Its probably very simple like the first questioned I asked, but I can't figure this one out. Any help?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.