Jump to content

[SOLVED] need help with important field in forum


runnerjp

Recommended Posts

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??

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.

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

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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.