Tedit kap wrote:
> Hi all,
> $query=mysql_query("select * from newsa ORDER BY id DESC LIMIT 3");
> while ($row = mysql_fetch_array($query)) {
> echo"..............
> if we say the id of rows goes from 1 to 100, so the last row's id is 100,
> this code displays the results for the ids as follows:
> row with id 98
> row with id 99
> row with id 100
> The question is, I want it to display as :
> row with id 100
> row with id 99
> row with id 98

Could you post your table description?

When I run the code:
$sql = 'SELECT * FROM ticket ORDER BY `ID` DESC LIMIT 3';
$res = mysql_query($sql, $conn);
while( $row = mysql_fetch_array($res) ) {
        echo $row['ID'].'<br />';
}

I get:
2852
2851
2850

When I run the code:
$sql = 'SELECT * FROM ticket ORDER BY `ID` ASC LIMIT 3';
$res = mysql_query($sql, $conn);
while( $row = mysql_fetch_array($res) ) {
        echo $row['ID'].'<br />';
}

I get (this is a live table where 1 and 4 has been deleted....:
2
3
5

Could you post the output of
     DESC YourTableName;

Reply via email to