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
FTP issues
Hi all,
I am currently facing some serious problems with a script and really need some ad
Need help with basic sql
Hi,
I am using oracle 10g, and having some small doubts related to sql , here goes the si
Conditions of info record - Error
When i created GR (901) and PO create automatic my PBXX is obtain the net price of info record but
Select question
Hi,
First I would like to say that php is pretty new for me..
so please don't shoot me if
What exactly is net neatrality?
What exactly is it? I think it's anti-censorship and... stuff... but I don't really understand it
Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn
Assume I know the fol
gmdate() - want 1 hr before time
Hi,
I am using php gmdate().
Now I am entering all dates in my dbase using gmdate("Y-m-d
Count
Getting the same count everytime
Code:
$visitquery = mysql_query("SELECT COUNT(*) FR
If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.
i have this c
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h