Gem Posted March 11, 2009 Share Posted March 11, 2009 Hiya, I've got this code that displays my articles ... but I need them to be displayed "newest first" .. Can anyone help me with that? <?php $con = mysql_connect("CONNECTION DETAILS"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("DBNAME", $con);$result = mysql_query("SELECT * FROM articles");while($row = mysql_fetch_array($result)) { echo $row['Title']; echo "<br />"; echo $row['SubTitle']; echo "<br />"; echo $row['Article']; echo "<br />"; }mysql_close($con); ?> Also, heres my form ... I cant get the textarea to display properly, it just displays the same as the other fields which is really annoying ... any ideas?? <form action="insert.php" method="post"> Title: <input type="text" name="title" /> Description: <input type="text" name="subtitle" /> News Update: <input type="textarea" name="article" /> <input type="submit" /> </form> Thanks loads Gem xxx Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/ Share on other sites More sharing options...
lonewolf217 Posted March 11, 2009 Share Posted March 11, 2009 do you have an index in your table ? if so just use "ORDER BY INDEX DESC" in your query Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/#findComment-782467 Share on other sites More sharing options...
redarrow Posted March 11, 2009 Share Posted March 11, 2009 DESC descending ASC ascending at the end off the sql. or you an use a ORDER BY Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/#findComment-782469 Share on other sites More sharing options...
Gem Posted March 11, 2009 Author Share Posted March 11, 2009 OK LOL - What did I do wrong? I just done the index on column "ID" - though I dont really know what that actually means ... so then I did this... }mysql_select_db("bssql", $con);$result = mysql_query("SELECT * FROM articles");while($row = mysql_fetch_array($result) ORDER BY INDEX SORT DESC;) and got this: PHP Parse error: syntax error, unexpected T_STRING in d:\webspace\bradleystokejudoclub.co.uk\wwwroot\news.php on line 17 Help ... ??? Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/#findComment-782476 Share on other sites More sharing options...
lonewolf217 Posted March 11, 2009 Share Posted March 11, 2009 it goes in the mysql_query statement not at the end of the line ... and take out the "SORT", that was a typo on my part }mysql_select_db("bssql", $con);$result = mysql_query("SELECT * FROM articles ORDER BY ID DESC");while($row = mysql_fetch_array($result) Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/#findComment-782480 Share on other sites More sharing options...
Gem Posted March 11, 2009 Author Share Posted March 11, 2009 Awsome, thanks for that! XXXXX Link to comment https://forums.phpfreaks.com/topic/149009-solved-reverse-order-and-form-trouble/#findComment-782490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.