djfox Posted July 14, 2007 Share Posted July 14, 2007 I am trying to get the forum to show sticky messages at the top with non-sticky messages below the stickies (I`m sure you`re familiar with nearly al forums doing this). But I can`t figure out how to get it to display that way. I have all the fields available for this in the database. But I can`t figure out how to get the php to work the way I need it to. Here`s what I`ve got: <table border=0 width=100%><? //5 ?> <tr> <td><b>Topic</b><td width=20%><b>Creator</b><td width=9%><b>Created</b><td width=8%><b>Replies</b><td width=9%><b>Update</b> <? $recent = 0; $res = mysql_query("SELECT id,user,subject,datetime,message_text,forum_id,recent,login,repl,sticky FROM forum WHERE forum_id=$id ORDER BY recent DESC")or die( mysql_error() ); while( ($fort = mysql_fetch_row($res)) && $recent < 25 ){ if( $recent%1 == 0 ){ echo "<tr><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><tr>"; } $recent = $recent + 1; echo "<td><font size=2><a href='thread.php?id=$fort[0]'>$fort[2]</a></font>"; echo "<td><font size=2><a href='trancer.php?id=$fort[1]'>$fort[7]</a></font>"; echo "<td><font size=2>$fort[3] </font><td><font size=2>$numCom[0] </font><td><font size=2>$fort[6] </font>"; } ?> </table><? //5 ?> It will display the threads just fine but I need the stickies to stick on top of the list. For the sticky field, 0 is for not a sticky message, and 1 is for sticky message. Quote Link to comment Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 $res = mysql_query("SELECT id,user,subject,datetime,message_text,forum_id,recent,login,repl,sticky FROM forum WHERE forum_id=$id ORDER BY sticky,recent DESC")or die( mysql_error() ); Try that? Quote Link to comment Share on other sites More sharing options...
djfox Posted July 15, 2007 Author Share Posted July 15, 2007 What ended up working was this: WHERE forum_id=$id ORDER BY sticky DESC, recent DESC Quote Link to comment Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 What ended up working was this: WHERE forum_id=$id ORDER BY sticky DESC, recent DESC WHERE forum_id=$id ORDER BY sticky DESC, recent DESC is identical to WHERE forum_id=$id ORDER BY sticky,recent DESC Quote Link to comment Share on other sites More sharing options...
djfox Posted July 15, 2007 Author Share Posted July 15, 2007 Oh I did not realize they were the same. Quote Link to comment 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.