Reply to Sort array from a Query

Your name:

Reply:


Posted by bettina on 11/29/05 19:38

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация