example db:
1 apple red 2 apple green 3 apple green 4 apple green 5 apple red
how do i get php + mysql to tell me how many green apples i have ?
thanks.
$query = "SELECT COUNT(id) AS amount FROM AppleTable WHERE item_name = 'apple' AND item_color = 'green'";
$result = mysql_query($query) or die(mysql_error());
$meta = mysql_fetch_object($result);
echo $meta->amount;
That ought to do the trick.