Jump to content

[SOLVED] Weird SELECT Issues


techiefreak05

Recommended Posts

I have a bulletin system on one o f my website's and it seemed to work semi-fine after some crap I had to go through. haha. but the following code, selects all your friends, then all the bulletins that were posted by your friiends, now it SHOULD have the most recent posted first, but it shows the bulletins bassed on User ID number, which I do not see why it's doing that.

 

Thanks for Any Help!

 

<table cellpadding="2" cellspacing="2" width="305" class="menuBlue">
<tr>
<td width="25%"><b>From</b></td width="25%"><td><b>Date</b></td><td width="50%"><b>Subject</b></td>
</tr>
<?php
$bulletin = "1";

if($bulletin == "1"){
$user = $_SESSION[id];
$queryF="SELECT friend FROM friends WHERE `username` = '$user' AND `accepted` = 'yes'"; // GET ALL YOUR FRIENDS
$resultF=mysql_query($queryF) or die(mysql_error());
while($array1=mysql_fetch_assoc($resultF)){
$POSTER=$array1['friend']; // Friends ID numbers


$queryB="SELECT * FROM `bulletins` WHERE `posterid` = '$POSTER' ORDER BY id DESC"; //GET BULLETINS POSTED BY YOUR FRIENDS
$resultB=mysql_query($queryB) or die(mysql_error());


while($array=mysql_fetch_array($resultB)){


?>
<tr>
<td id="bulletins" bgcolor="#D6EAFE">
<b><a class="blue" href="http://profiles.profileflip.com/index.php?id=<?php echo $array['posterid']; ?>"><?php echo stripslashes(stripslashes($array['postername'])); ?></a></b>
</td>
<td id="bulletins" bgcolor="#D6EAFE">
<?php 

$now=time();
$dateNow = date("M. d, Y",$now);
$dateThen= date("M. d, Y",$array['date']);
$thenTime = date("g:i",$array['date']);

if($dateNow == $dateThen){ 
echo "Today at " . $thenTime; 
}else{ 
echo $dateThen;
} 

?>
</td>
<td id="bulletins" bgcolor="#D6EAFE">
<a href="showBulletin.php?id=<?php echo $array[id]; ?>" class="blue"><?php echo stripslashes(stripslashes($array['subject'])); ?></a>
</td>
</tr>
<?php
}
}
}else{
?>
<tr bgcolor="#FFFFFF">
<td colspan="3">
<b>Bulletins are down for maintanance!</b>
</tr>
<?php
}
?>
</table>

Link to comment
Share on other sites

$queryB="SELECT * FROM `bulletins` WHERE `posterid` = '$POSTER' ORDER BY id DESC"; //GET BULLETINS POSTED BY YOUR FRIENDS

 

change it to

 

$queryB="SELECT * FROM `bulletins` WHERE `posterid` = '$POSTER' ORDER BY dateposted DESC"; //GET BULLETINS POSTED BY YOUR FRIENDS

 

change dateposted to whatever you have the time/date it was posted set as.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.