I've got a database of tire reviews. I want to query the db and return which manufacturers have tires reviewed in the db, and how man reviews they have, generating a list that looks something like this:
The following tire manufacturers have reviews in the DB:
- Firestone (2)
- BF Goodrich (6)
- Super Swamper (1)
- Bridgetsone (3)
The list of manufacturers will be generated by the select statement. For this, I'm currently using the following, which works fine:
SELECT DISTINCT TireMake FROM trucktires ORDER BY TireMake
How do I add the ability to count how many records there are for each manufacturer? I tried this:
$db = mysql_connect("localhost", "root");
mysql_select_db("tires",$db);
$result = mysql_query("SELECT DISTINCT TireMake, COUNT(*) FROM trucktires ORDER BY TireMake",$db);
if ($record = mysql_fetch_array($result)) {
but got the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache\Apache2\htdocs\TireReport.php on line 88
Thanks.