Jump to content

SQL Pulling in order, how out of order? :P


AbydosGater

Recommended Posts

Hi, Sorry for the topic name!, bit confusing... But
Heres my script...

[code]
$query = "SELECT * FROM ben_news ORDER BY id";
$result = mysql_query($query);
while($news = mysql_fetch_array($result)) {
$member_id = $news['member_id'];
$author = "SELECT username FROM ben_users WHERE member_id='$member_id'";
$authorresult = mysql_query($author);
$authorinfo = mysql_fetch_array( $authorresult );
echo "<table width='455' border='0' cellspacing='0' cellpadding='0' background='image/longmenu.gif' height='34'>
        <tr>
          <td><FONT FACE='Tahoma'><b>" . $news['title'] . "</b></FONT></td>
        </tr>
      </table> ";
echo "<p>";
echo $news['content'];
echo "</p>";
echo "<p>";
echo "<hr><br>";
echo "Author: &nbsp; " . $authorinfo['username'] . "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " . "Date/Time:&nbsp; " . $news['timedate'];
echo "</p>";
};

};

[/code]


Right no need to read all of that, but the Important bit is $query = "SELECT * FROM ben_news ORDER BY id";

The id field is an Auto Int.. And it all works fine! but i was wondering how do i get it to order backwards? start with the highest number, 5,4,3,2,1... and so on???

Thanks
Abydos
Link to comment
https://forums.phpfreaks.com/topic/23283-sql-pulling-in-order-how-out-of-order-p/
Share on other sites

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.