runnerjp Posted May 31, 2008 Share Posted May 31, 2008 hey guys need some ideas and aid on this ok here is my current script <table class='maintable'> <tr class='headline'><td colspan="3">Topic</td><td width=20%>Topic Starter</td><td width="5%">Replies</td><td width="25%">Last replied time</td></tr> <?php $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY lastrepliedto DESC $max"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $getthreads3[important]=strip_tags($getthreads3[important]); $important=$getthreads3['important']; ?> <tr <?php if($important==1) { $class = "mainrow1"; } else { $class = "mainrow"; } ?> class="<?php echo $class?>"><td width="3%" align="center"><?php if($getthreads3[author] == $puser){ ?> <img src="http://www.runningprofiles.com/images/new_posts_icon.gif" alt="My" /> <?php } else { ?> <img src="http://www.runningprofiles.com/images/last_post.gif" alt="My" /> <?php } ?> <td width="4%" align="center" valign="middle"><?php if($getthreads3['forumlock'] == 1){echo' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>';} ?></td> <td><a href='index.php?page=message&forum=<?php echo $forum; ?>&id=<? echo $getthreads3[postid] ?>'><?php echo $getthreads3[title] ?></a> <?php if($id == 1){ include 'editforum.php'; };?></td> <td><?php echo $getthreads3[author]?> </td><td align="center"><?php echo $getthreads3[numreplies]?></td> <td><?php echo $getthreads3[showtime]?><br>Last post by <b><?php echo $getthreads3[lastposter]?> </b></td></tr> <? } ?> </table> but what i would like to do is the if in my db the field "important" is set to 1 then it will show it always at the top of the forum.. like it is on here where the top 4 are important threada nd then under it other thread are displayed any ideas?? Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/ Share on other sites More sharing options...
soycharliente Posted May 31, 2008 Share Posted May 31, 2008 What number do you use for not important? Use 2. Then use MySQL to ORDER BY important And if you want it to be ordered by when they posted as well, then use multiple fields in your ORDER BY. ORDER BY important, post_date, post_author That would order the posts by numerical importance (1 - whatever), then by chronology, then by alphabetical in author name. Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554295 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok i have done this $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY important,lastrepliedto DESC $max"; my normal posts = 0 and important = 1 i does not orderthem by importance tho lol Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554297 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 humm ok so just thought DESC lol sooooo if my normal posts = 1 and important =0 then it would work Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554299 Share on other sites More sharing options...
soycharliente Posted May 31, 2008 Share Posted May 31, 2008 Or change to ASC. If I'm not mistaken, you can do something like... ORDER BY important ASC, lastrepliedto DESC Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554300 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok i did this $data = mysql_query("Select * from forumtutorial_posts where parentid='0' AND forum = '$forum' ORDER BY important, lastrepliedto") and it puts the important 1st but then under it it does not order the rest by date May 30, 2008, 11:20 pm Last post by Admin [color=green]^ this one is my important one[/color] May 31, 2008, 2:37 pm Last post by Admin May 31, 2008, 5:09 pm Last post by Admin i need it to show like this May 30, 2008, 11:20 pm Last post by Admin [color=green]^ this one is my important one[/color] May 31, 2008, 5:09 pm Last post by Admin May 31, 2008, 2:37 pm Last post by Admin Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554303 Share on other sites More sharing options...
soycharliente Posted May 31, 2008 Share Posted May 31, 2008 It is. It's just doing it by it's default. It's doing the oldest first. Try adding ASC/DESC so it filters both. ORDER BY important ASC, lastrepliedto DESC But If you go back to 1 for important and 0 for not, using DESC should fix both problems. ORDER BY important, lastrepliedto DESC Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554318 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 well i put it as you said 0 for normal 1 for important but its only ordering it by lastrepliedto and not important Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554321 Share on other sites More sharing options...
soycharliente Posted May 31, 2008 Share Posted May 31, 2008 Try 1 and 2. Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554333 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok i made 1 for normal 2 for important and put 1 on top then but inthen in decing order of time so then i went with important ASC, lastrepliedto DESC but it stock improtant on top then went down in time again form yesterday to today Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554345 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok been messing around loads and it still aint working...how comes Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554370 Share on other sites More sharing options...
soycharliente Posted May 31, 2008 Share Posted May 31, 2008 Then change to order by important, lastrepliedto asc I don't know why it's not working. I don't have your code or your db. It's just going to have to be trial and error until you figure it out. Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554371 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok i have done it wahoo i just changed it to rather then last replied i went by time and did new field...cheers Link to comment https://forums.phpfreaks.com/topic/108141-solved-need-help-with-important-field-in-forum/#findComment-554389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.