Jump to content
MakeWebGames

mysql_fetch_assoc in reverse order?


schloob

Recommended Posts

I am using mysql database entries to store my chat and my announcements. Each one has an incremented id. When I use mysql_fetch_assoc to list all of the records it lists them from oldest to newest. I know that I can store them in an array and then work backwards from the newest but I was wondering if there was a way to just reverse the order of mysql_fetch_assoc. Thanks.

Link to comment
Share on other sites

Re: mysql_fetch_assoc in reverse order?

$sel = mysql_query("SELECT rows FROM `table` ORDER BY `increment_id` ASC");

And if you want to limit the list:

$sel = mysql_query("SELECT rows FROM `table` ORDER BY `increment_id` ASC LIMIT limitnumber");

Then you just call it out.

while($soc = mysql_fetch_assoc($sel))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...