rallokkcaz Posted May 5, 2007 Share Posted May 5, 2007 i wanna make it so when i list the topics in my news page it shows them the oppisite way instead of the the articles going 1, 2, 3. i want them to appear 3, 2, 1. here if the code for the view page. <?php include 'header.php'; //connect to and select db $conn = mysql_connect(INFOICANTSHOWGOESHERE!) or die(mysql_error()); $db = mysql_select_db('pokebash_users',$conn) or die(mysql_error()); //get a list of the info from the table to make the linkies $sql = "select * from news LIMIT 3"; $result = mysql_query($sql, $conn) or die(mysql_error()); // for each row fetched from the results... while ($list = mysql_fetch_array($result)) { //make the custom linkie echo " <fieldset style='padding:5px; width:500px;'> <legend>"; echo $list['topic'] ; echo " "; echo "Posted at: "; echo $list['time'] ; echo " </legend> <table cellpadding='10px'> <tr> <td> "; echo $list['content'] ; echo " </td> </tr> </table> </fieldset><br> <a href='http://www.getmetola.com/post.php?id={$list['id']}'>View Topic</a> <br> <br> "; } // end while // if the user clicked on a linkie and therefore an id exists (the is_numeric is a basic security precaution) ... if (is_numeric($_GET['id'])) { // for easier var syntax handling $id = $_GET['id']; $sql = "select topic from news where id = '$id'"; $result = mysql_query($sql, $conn) or die(mysql_error()); $userfound = mysql_num_rows($result); if ($userfound) { $user = mysql_fetch_array($result); } // end if found } // end if there was a linkie clicked ?> anyone know or is my description not good enough? Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/ Share on other sites More sharing options...
mmarif4u Posted May 5, 2007 Share Posted May 5, 2007 Try order by clause. Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245922 Share on other sites More sharing options...
rallokkcaz Posted May 5, 2007 Author Share Posted May 5, 2007 so how would that look like? Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245923 Share on other sites More sharing options...
mmarif4u Posted May 5, 2007 Share Posted May 5, 2007 I dont know what is field in db for 1,2,3. Change the value in ur query below. $sql = "select * from news LIMIT 3 ORDER BY id desc"; Change id to ur desired db field. Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245925 Share on other sites More sharing options...
rallokkcaz Posted May 5, 2007 Author Share Posted May 5, 2007 i get this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY id desc' at line 1 what does that mean Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245928 Share on other sites More sharing options...
suttercain Posted May 5, 2007 Share Posted May 5, 2007 Can you repost your new code that you're getting the error from? Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245930 Share on other sites More sharing options...
mmarif4u Posted May 5, 2007 Share Posted May 5, 2007 What is field name in table for 1,2,3. Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245932 Share on other sites More sharing options...
rallokkcaz Posted May 5, 2007 Author Share Posted May 5, 2007 the field name is id Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245935 Share on other sites More sharing options...
mmarif4u Posted May 5, 2007 Share Posted May 5, 2007 Post ur update code. Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245936 Share on other sites More sharing options...
rallokkcaz Posted May 5, 2007 Author Share Posted May 5, 2007 hey i would but i g2g sorry guys night! Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245937 Share on other sites More sharing options...
suttercain Posted May 5, 2007 Share Posted May 5, 2007 WTF? Quote Link to comment https://forums.phpfreaks.com/topic/50088-mysql-arrangement-help/#findComment-245938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.