Reputation: 21
I can't seem to get ORDER BY to work with my current MySQL Query I'm using!
$query = "SELECT * FROM games WHERE game_platform = '$gameType' ORDER BY ASC";
$result = mysql_query($query);
I just get the following error.
Warning:
mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
Upvotes: 1
Views: 840
Reputation: 888
Try this code:
$query = "SELECT * FROM games WHERE game_platform = '$gameType' ORDER BY game_platform ASC";
$result = mysql_query($query);
Refer: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html
Upvotes: 1
Reputation: 5588
Please enter colname :
$query = "SELECT * FROM games WHERE game_platform = '" . $gameType .
"' ORDER BY colname ASC ";
$result = mysql_query($query);
Upvotes: 1
Reputation: 79929
ORDER BY
what??
You didn't specify what column to order by. You have to specify the order columns. Something like so.
ORDER BY somefield ASC
However, if you have a column called ASC
in your table and you want to order by it, you have to escape it like so:
ORDER BY `ASC`
Since ASC
is a reserved word.
Upvotes: 10