Jump to content

PHP Forum help?


lalnfl

Recommended Posts

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
https://forums.phpfreaks.com/topic/209827-php-forum-help/#findComment-1095270
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
https://forums.phpfreaks.com/topic/209827-php-forum-help/#findComment-1095294
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.