Jump to content

Recommended Posts

How can i select the last 3 rows in a table and order it by ASC. When i use DESC it displays the results in the wrong order.

 

$query24 = mysql_query("SELECT * FROM notifications WHERE to_id='$session' AND state='1' ORDER BY id DESC LIMIT 3 ");

use DESC/ASC whatever you want to and do this...

$query24 = mysql_query("SELECT * FROM notifications WHERE to_id='$session' AND state='1' ORDER BY id DESC LIMIT 3 ");
$i=mysql_num_rows($query24)-1;
while($row=mysql_fetch_array($query24)){
  $array[$i]=$row;
  $i--;
}

should give you an idea on how to solve it, it's all about finding a nice way to solve the problem.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.