Fsoft Posted July 17, 2009 Share Posted July 17, 2009 Hello, $query2 = mysql_query("SELECT * FROM articles where art_cat = $cat"); while($art_infos = mysql_fetch_array($query2)) { echo $art_infos["art_title"]; } Using this code above, I am able to echo out all the existing art titles available in my database, the only problem is, their order is from new older to new. I mean the title on top is older and the title on the last is the newer. I want them in reverse order, so from NEW to OLD which makes a sense. I tried to use array_reverse. But it doesn't seem to work. Please help me, how can I echo them out in reverse order? Thanks a lot. FAISAL!!!!!!! Quote Link to comment Share on other sites More sharing options...
WolfRage Posted July 17, 2009 Share Posted July 17, 2009 http://us2.php.net/manual/en/function.array-reverse.php Quote Link to comment Share on other sites More sharing options...
Fsoft Posted July 17, 2009 Author Share Posted July 17, 2009 http://us2.php.net/manual/en/function.array-reverse.php Yes that I already saw, but in this code, where I can place the array_reverse to get it workign? I tried but it is not working...! Quote Link to comment Share on other sites More sharing options...
WolfRage Posted July 17, 2009 Share Posted July 17, 2009 <?php $query2 = mysql_query("SELECT * FROM articles where art_cat = $cat"); while($art_infos = array_reverse(mysql_fetch_array($query2))) { echo $art_infos["art_title"]; } ?> Quote Link to comment Share on other sites More sharing options...
mattal999 Posted July 17, 2009 Share Posted July 17, 2009 Or: <?php $query2 = mysql_query("SELECT * FROM articles where art_cat = $cat ORDER BY art_title ASC"); while($art_infos = mysql_fetch_array($query2)) { echo $art_infos["art_title"]; } ?> EDIT: That should work. Quote Link to comment Share on other sites More sharing options...
Fsoft Posted July 17, 2009 Author Share Posted July 17, 2009 Thanks friends, but sadly non of them worked ... The 1st one "WolfRage" gives an error... And mattal999 was suppose to work but actually no it gives up same result as if I do it without changing my query Any other help??? Thanks... Quote Link to comment Share on other sites More sharing options...
.josh Posted July 17, 2009 Share Posted July 17, 2009 As mattal999 mentioned, you'll want to order it in your query. You are saying you want "newer" ones first. Which column in your table signifies older vs. newer? Is there a date column? Id column? You will want to ... ORDER BY column DESC Quote Link to comment Share on other sites More sharing options...
Fsoft Posted July 17, 2009 Author Share Posted July 17, 2009 WOW!!!!!! Thanks Crayon Violent.. I will never forget this thing Thanks a lot.If I get an other problem will post here, this forum always helps me ... like always.. FAISAL! Quote Link to comment 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.