Sort array from a Query
- From: bettina@xxxxxxxxxx
- Date: 29 Nov 2005 09:38:11 -0800
I have 2 tables (simplified):
coasters (ID,BREWERY_CODE, etc)
breweries (BREWERY_CODE, BREWERY)
For each brewery I want to count how many coasters are there in table
"coasters" (up to here it works fine) and then I want to show them
ordered by quantity (that's my problem):
The following is the piece of code.
......
$search_breweries = mysql_query("SELECT BREWERY_CODE, BREWERY FROM
breweries");
$i = 0;
while ($row = mysql_fetch_array($search_breweries, MYSQL_NUM)) {
$breweries[$i][0] = $row[0];
$breweries[$i][1] = $row[1];
$key_brewery = $row[0];
$count_coasters_brewery = mysql_query("SELECT COUNT(*) FROM coasters
WHERE BREWERY_CODE = $key_brewery");
$breweries[$i][2] = mysql_result($count_coasters_brewery,0,0);
$i = $i + 1;
}
I suppose I have to assign everything to an array and then sort it, but
I don't know how.
Any help will be welcomed.
Bettina
.
- Follow-Ups:
- Re: Sort array from a Query
- From: Sean
- Re: Sort array from a Query
- From: Ewoud Dronkert
- Re: Sort array from a Query
- Prev by Date: Re: IIS configuration
- Next by Date: Re: include_once/__autoload/namespace emulation ...
- Previous by thread: confused: casting a variable to integer
- Next by thread: Re: Sort array from a Query
- Index(es):
Relevant Pages
|