red-x Posted October 10, 2008 Share Posted October 10, 2008 I'm trying to make my own forum but I'm not sure how to make a thread sticky or always stay on top of the other ones. I want something like.. if ($row["sticky"] == "yes") { make it stay on top of other threads. } How can I do this? Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/ Share on other sites More sharing options...
taith Posted October 10, 2008 Share Posted October 10, 2008 easiest way, would prolly to do 2 mysql querys... #query for stickys ouput #query for rest, order by `id` DESC output Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661606 Share on other sites More sharing options...
corbin Posted October 10, 2008 Share Posted October 10, 2008 You could just order by sticky or not. SELECT * FROM table ORDER BY stickied, when_written DESC; Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661607 Share on other sites More sharing options...
iversonm Posted October 10, 2008 Share Posted October 10, 2008 well how i owuld go about doing this is call all the sticky rows and echo them in a while statement then call the non sticky rows and echo them in a while statement like so $q="SELECT * FROM table WHERE type='sticky' ORDER BY time"; $query=mysql_query($q); while($myrow=mysql_fetch_array($query)){ $myrow[] echo your threads } $qnonsticky="SELECT * FROM table WHERE type='nonsticky' ORDER BY time"; $nonstickyquery=mysql_query($qnonsticky); while($myrow=mysql_fetch_array($nonstickyquery)){ $myrow[] echo your non sticky threads } anyways that is how about would go about doing that, it is simple and it works. then if you wanna stick a thread just change the type from nonsticky to stick and it will put it to the top idk.. i tried Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661609 Share on other sites More sharing options...
corbin Posted October 10, 2008 Share Posted October 10, 2008 A numeric data type for stickied or not would be quicker. I guess it could be an announcement or something though.... So I guess multiple options might be needed. Why bother with two queries? If you make it numeric, you can just order by stickied and if it is stickied, it will be in the top of the result set ;p. Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661612 Share on other sites More sharing options...
iversonm Posted October 10, 2008 Share Posted October 10, 2008 see corbin that is why you are a PHP Help Guru and have let me count 1,2,3... 10 stars and i have let me count 0 stars anyways do what corbin said Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661619 Share on other sites More sharing options...
red-x Posted October 10, 2008 Author Share Posted October 10, 2008 Thank you so much guys. You guys are awesome, I'm going to try all of them to see which one works better Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661623 Share on other sites More sharing options...
corbin Posted October 10, 2008 Share Posted October 10, 2008 ;p Link to comment https://forums.phpfreaks.com/topic/127802-make-a-sticky-thread-own-forum/#findComment-661628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.