virtuexru Posted November 15, 2006 Share Posted November 15, 2006 OK.. so I have this and it works:[quote]$query = "SELECT title, category, salary, location, number FROM joborder WHERE category='Development' LIMIT 3"; $result = mysql_query($query); while(list($title,$category,$salary,$location,$number) = mysql_fetch_row($result))[/quote]But this won't work:[quote]$query = "SELECT title, category, salary, location, number FROM joborder ORDER BY number ASC WHERE category='Development' LIMIT 3"; $result = mysql_query($query); while(list($title,$category,$salary,$location,$number) = mysql_fetch_row($result))[/quote] Link to comment https://forums.phpfreaks.com/topic/27341-help-with-order-by-function/ Share on other sites More sharing options...
Cep Posted November 15, 2006 Share Posted November 15, 2006 Its because you have ASC after number before the WHERE clause, ASC should appear at the end of the sql statement.And just so your wondering why no one else has replied to your message its because you didnt really tell anyone why it wasn't working, I on the other hand am just guessing that this is the cause of your problem. Link to comment https://forums.phpfreaks.com/topic/27341-help-with-order-by-function/#findComment-125016 Share on other sites More sharing options...
virtuexru Posted November 15, 2006 Author Share Posted November 15, 2006 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /**/**/**/**/index.php on line 141$query = "SELECT title, category, salary, location, number FROM joborder ORDER BY number WHERE category='Development' LIMIT 3 ASC"; $result = mysql_query($query);while(list($title,$category,$salary,$location,$number) = mysql_fetch_row($result)) Link to comment https://forums.phpfreaks.com/topic/27341-help-with-order-by-function/#findComment-125036 Share on other sites More sharing options...
Nicklas Posted November 15, 2006 Share Posted November 15, 2006 ORDER BY and LIMIT should always be in the end of your queryex[code=php:0]SELECT title, category, salary, location, number FROM joborder WHERE category='Development' ORDER BY number ASC LIMIT 3[/code]Your query can also be written like this:ex[code=php:0]SELECT * FROM joborder WHERE category='Development' ORDER BY number LIMIT 3[/code] Link to comment https://forums.phpfreaks.com/topic/27341-help-with-order-by-function/#findComment-125037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.