Search code examples
phpmysqlsyntax-error

How to get ascending data in php?


I want to get the data from the database in ascending order using the PHP function:

What I tried so far:

$query = "select * from posts order by DESC LIMIT 0,1200";

$run = mysql_query($query);

while($row=mysql_fetch_array($run)){
$post_id = $row['un_id'];
$title = $row['post_title'];
$image = $row['post_image']; }

Everything seems to work fine until changed the order from DSEC to ASE, and PHP generates the error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in...

UPDATE: I solved it by myself, I updated the question for future visitors


Solution

  • ASE doesn't exist, it's ASC and DESC.

    Try this request:

    $query = "select * from posts order by un_id ASC LIMIT 0,1200";