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
Estimations and Effort
HI Gurus,
Would like to know whether SAP have a provision for carrying out the Project es
mysq_num_rows
Hi,
I want to use:
Code: if(mysql_num_rows($ergebnis2)==2)
how can the value 2, be
Contents of variable not echoing
Hey guys, hopefully this is an easy one...
In this line, the variables are not echoing out. T
help understanding hidden input w/ php
hello i'm doing a tutorial where there are multiple forms for an edit page for a user to update thei
parse error
Parse error: syntax error, unexpected '[', expecting ')' in /Users/admin/Sites/phptest/array.php on
Help with forum quoting?
Hi im working on a forum and I have alomost finished it but i want a user quote system like twitter
Why Are These Functions Causing MASSIVE Memory Problems? Please Help!
Hi,
I have a script with some options.
I use regex to replace patterns in strings, but
Weird problem with SELECT command..Help!
Hi!
It seems I'm having a really weird problem with SQL SELECT command....I have table into a
User input in to variable
Hi all,
I'm sure this is very easy but I'm having another brain freeze!
At the end of
Calling variables
I want to call this to my website but it doesn't display what I want it to,
Code: <h5&