Jump to content

display sql asc


leequalls

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/186310-display-sql-asc/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-983915
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-984003
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/186310-display-sql-asc/#findComment-984125
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.