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
mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???
this is the code i got
I am stumped
OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want
Stumped by Third Day of Month problem
I am trying to build an algorithm that will essentially do this:
Code: [Select]$this_month = Oct
remove innitial and
tags
i am using tiny_mce as a text editor for my CMS.
buy now the problem is it add <p>
Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use
How to file_get_contents when login required?
Hello!
I am trying to read data from a page that you have to be logged into to view, I am try
Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of
Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d
Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot
Loosing changed contents when used FM REUSE_ALV_GRID_DISPLAY
Hi,
I have used FM REUSE_ALV_GRID_DISPLAY in my program as below.
CALL FUNCT