So, my code looks like this
mysql_query("SELECT * FROM threads WHERE forum_id = '$id' ORDER BY type,posted DESC") or
die(mysql_error());
“posted” is the value of time() and is selected decreased to put the latest one at the top.
“type” contains either 1 or 2. If it’s 2, the thread is pinned. Currently, it sorts after posted but those which should be at the top (pinned) are at the bottom. Is there any fix that I’m missing?
Try:
ORDER BY type DESC, posted DESCBy default, it sorts ascending. You need to specify the order for both fields you would like to order by.
ORDER BY Documentation