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
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
php problem?
I don't think I'm stupid, but maybe I am.
I am working on a sit for a friend I am try to put
need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen
Material Issuing for receiving batch
Dear All experts in MM/ PP,
Material issuing from main stores to factory is currently usi
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
1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.
In some case, there will be 100+ of the
How to implement HTTP connection timeout
Hi All,I would like to implement an HTTP connection timeout.
I am working on a application wh
first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see
Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so
quick question
Hi ..
i have a question
how do i set a var so it displays via an echo
Code: $logo = '&a
b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)