Grouping and sorting results
Posted on
16th Feb 2014 07:03 pm by
admin
Please help with this query.
I have 2 tables in a database, countires and cities. states looks like this
Did you know?Explore Trending and Topic pages for more stories like this.
countries
id -----------country
1 ------------uk
2 ------------us
3 ------------japan
cities
id ---country ----city
1 ----1 ----------London
2 ----1 ----------Manchester
3 ----2 ----------New York
4 ----2 ----------Washington
5 ----2 ----------San Francisco
6 ----2 ----------Las Vegas
7 ----2 ----------New Orleans
8 ----3 ----------Tokyo
I have queried the database as follows:
///////////////////////// Make the country query //////////////////////////////
$q_country = "SELECT * FROM countries";
$result_country = mysqli_query($dbc, $q_country);
$row_country = mysqli_fetch_array($result_country);
///////////////////////// Make the city query //////////////////////////////
$q_city = "SELECT * FROM cities";
$result_city = mysqli_query($dbc, $q_city);
$row_name = mysqli_fetch_array($result_name);
I want to display the data as follows:
Country - UK
Cities - London, Manchester
Country - US
Cities - New York, Washinton, San Francisco, Las Vegas, New Orleans
Country - Japan
Cities - Tokyo
I'm new to PHP and just can't work it out. Please can somebody point me in the right direction?!!!! PLEASE!!!!!
No comments posted yet
Your Answer:
Login to answer
98
7
Other forums
cURL Upload Help
OK, I am creating a bridge from a local program to my website and I am trying to find the best way t
disable all input buttons
Hello Friends,
suppose i do have a file ( file.php ) has a submit button
Code: [Sele
Blocking video streaming
Hello everyone,
I post a message here because i didn't find any solution yet.
I just finis
Map.php
I am a complete beginner to PHP and am looking for some help with a program I am messing around with
Seperate team from score
I am writing a site that does a NFL Pick 'em type application and I have a feed that gives me the sc
Socket problem
Hello,
Earlier I posted about my problem with my socket script. It took up to 100% CPU usage.
SCO Unix
I know this might not be the place to ask, but, can anyone tell me if SCO Unix comes with PHP built
strptime() equivalent for php4 ?!
Greetings!
this is my first post, thank you in advance for your replies.
Well, the ti
mysql_query returning boolean instead of mysql ressource
Hi,
I seem to have a weird issue with the php command mysql_query. I pass 2 arguments the que
Interpret Order
Hello all,
I'm wondering if I have this:
Code: $switch = array(
'one' =>