Neroo Posted July 29, 2013 Share Posted July 29, 2013 I'm currently creating my own Forum on my website and I need some help with my SQL query please. $gettopic=$db->query("SELECT * FROM forum_topics WHERE forum='{$id}' ORDER BY pinned ASC, time DESC LIMIT 20"); When topics are pinned, their column goes to 1, so when there are pinned topics in that forum, they need to be at the top of the list while all other times need to be ordered by their time. Quote Link to comment https://forums.phpfreaks.com/topic/280624-sql-help-please/ Share on other sites More sharing options...
AbraCadaver Posted July 29, 2013 Share Posted July 29, 2013 (edited) So they'll be 1 if pinned and 0 if not? Did you try: pinned DESC ? Edited July 29, 2013 by AbraCadaver Quote Link to comment https://forums.phpfreaks.com/topic/280624-sql-help-please/#findComment-1442594 Share on other sites More sharing options...
Neroo Posted July 29, 2013 Author Share Posted July 29, 2013 I tried that, but they all showed up as pinned for some strange reason Quote Link to comment https://forums.phpfreaks.com/topic/280624-sql-help-please/#findComment-1442595 Share on other sites More sharing options...
Neroo Posted July 29, 2013 Author Share Posted July 29, 2013 if($t['pinned'] == 1) { $p=" <img src='/images/forums/pinned.png' title='Pinned' height=12 width=12>"; } else { $p=""; } Eurgh, nevermind. I forgot to add the else, so they were all showing the pinned icon *facepalm* all fixed Quote Link to comment https://forums.phpfreaks.com/topic/280624-sql-help-please/#findComment-1442596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.