Jump to content

Recommended Posts

All my threads on my forum are sorted by the fields: sticky, lastbump, lastpost

 

Here is the part of my query:

ORDER BY `sticky` DESC, `lastbump` DESC,`lastpost`DESC

 

For some reason, even if the lastpost DATE field is newer than the lastbump (PHP's time() function) field, the thread won't be moved to the top of the forum. It seems to only sort by lastbump.

 

E.G:

 

I make a new reply to a thread that's near the bottom of the forums. It updates the lastpost field with the new date. But, it doesn't go to the top of the forums. It stays where it is in the list, and only moves to the top of the forums when the lastbump field is updated.

Link to comment
https://forums.phpfreaks.com/topic/264673-threads-sort-incorrectly/
Share on other sites

Well yeah: because you're sorting by the lastbump before the lastpost.

 

What's the difference between a bump and a post? Are those two different things? Can someone bump a thread without posting?

 

I tried switching the positions, but it still didn't work properly.

 

And yes. There's a little button for post owners to bump their threads without having to actually reply.

I tried switching the positions, but it still didn't work properly.

And then it would sort by bump first and most recent post second.

 

It'd be nice if you had one field with the most recent action, be that bump or post, but that might not be a good option. So

SELECT ..., IF(lastbump > lastpost, lastbump, lastpost) AS lastaction ... ORDER BY sticky DESC, lastaction DESC

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.