leequalls Posted December 25, 2009 Share Posted December 25, 2009 I have a sql database that has a list of users and there city, state and country I am trying to display the sql where it will show all users from Country then state then city in alphabetic order so it will look something like this City State Country Victoria Australia Albany Canada Duncan Canada Ontario Toronto Canada Hamberg Germany Berlin Pankow Germany England Stoke UK Arizona Tuscow USA Mimai Florida USA WPB Florida USA and so on... Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/ Share on other sites More sharing options...
premiso Posted December 25, 2009 Share Posted December 25, 2009 SELECT City, State, Country FROM users ORDER BY Country, State, City Should be what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-983907 Share on other sites More sharing options...
leequalls Posted December 25, 2009 Author Share Posted December 25, 2009 is this correct? $personality = mysql_query("select * from rp_staff ORDER BY `rp_staff`.`country`,`rp_staff`.`state,`rp_staff`.`city` ASC"); I am getting an error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/party/public_html/en/personalities.php on line 101 Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-983915 Share on other sites More sharing options...
premiso Posted December 25, 2009 Share Posted December 25, 2009 To find the error use this: $personality = mysql_query("select * from rp_staff ORDER BY `rp_staff`.`country`,`rp_staff`.`state,`rp_staff`.`city` ASC") or trigger_error("Query Failed: " . mysql_error()); And see what error is returned from the query. Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-984003 Share on other sites More sharing options...
leequalls Posted December 26, 2009 Author Share Posted December 26, 2009 Notice: Query Failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rp_staff`.`city` ASC' at line 1 in /home/party/public_html/en/personalities.php on line 101 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/party/public_html/en/personalities.php on line 102 Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-984125 Share on other sites More sharing options...
leequalls Posted December 26, 2009 Author Share Posted December 26, 2009 I found the error thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-984126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.