Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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