Can I assign “0” value on an array that returned no results from a MySQL Query?
If so, can you show me how?
my code goes something like this:
$grapes_query = mysql_query("SELECT fruitDate, fruitName, COUNT(*) FROM tbl_fruits WHERE fruitName='Grapes' GROUP BY
fruitDate");
while ($grapes = mysql_fetch_assoc($grapes_query)){
$grapes_array[]=$grapes['COUNT(*)'];
}
What if in a day, no grapes were found, can I assign “0” to its array value?
Let’s say 1/1/2012 = 3 grapes were counted, 1/2/2012 = no grapes were counted, 1/3/2012 = 5 grapes were counted..so the array should be like this.
$grapes_array[0]=3;
$grapes_array[1]= <-- i want to assign a string or number here when a MySQL query is empty.
$grapes_array[2]=3;
i’m getting errors if no value was found.
UPDATE:

fruit names should be grapes…:(
UPDATE 2:
HERE is my sample database being used.

Here is the result I’m getting on your updated query

The updated query will provide dates where there are fruit counts, but no Grapes counted on that day