EvanMartin Posted September 11, 2006 Share Posted September 11, 2006 Im making a script to display the newest threads from my forum. I need to know how i can get the newest threads names in order.Here's what i have so far.....[quote]<?phpmysql_connect("********", "*******", "*******") or die(mysql_error());mysql_select_db("******") or die(mysql_error());$forum_post = mysql_query("SELECT * FROM forum_thread")or die(mysql_error()); while($row = mysql_fetch_array( $forum_post )) {$topic1 = $row['title'];$topic2 = $row['title'];$topic3 = $row['title'];$topic4 = $row['title'];$topic5 = $row['title'];$topic6 = $row['title'];$topic7 = $row['title'];} echo "<table border='1'>";echo "<tr> <th colspan=\"2\"> Recent Forum Threads</tr><tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic1</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic2</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic3</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic4</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic5</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic6</th> </tr>";echo "<tr> <th><img src='http://homepages.xnet.co.nz/~jems.martin/images/arrow.gif'></th> <th>$topic7</th> </tr>";echo "</table>";echo "<P/\>";?>[/quote]That displays the newest thread fine but dosent display the the 2nd newest 3rd newest 4th newest ectAny help will be greatly appreciated.. Thanks Evan! Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/ Share on other sites More sharing options...
Daniel0 Posted September 11, 2006 Share Posted September 11, 2006 You could do something like: [code]SELECT * FROM topics ORDER BY id DESC LIMIT 10;[/code] or [code]SELECT * FROM topics ORDER BY date DESC LIMIT 10;[/code] (date will have to be a timestamp) Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/#findComment-89676 Share on other sites More sharing options...
fenway Posted September 11, 2006 Share Posted September 11, 2006 Definitely use the latter (though don't call your column "date")... you shouldn't rely on the UIDs being in any order whatsoever. Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/#findComment-89793 Share on other sites More sharing options...
EvanMartin Posted September 11, 2006 Author Share Posted September 11, 2006 Hmmm, That just about works... but it displays the oldest rather than the newest, Thanks tho :P Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/#findComment-89968 Share on other sites More sharing options...
EvanMartin Posted September 11, 2006 Author Share Posted September 11, 2006 Here is the link to the script [url=http://main.synthetic.net.nz/mysql.php]http://main.synthetic.net.nz/mysql.php[/url] Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/#findComment-89969 Share on other sites More sharing options...
fenway Posted September 11, 2006 Share Posted September 11, 2006 So you decided to sort by what? Link to comment https://forums.phpfreaks.com/topic/20351-display-newest-mysql-data/#findComment-89998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.