i'm grabbing months from a DB...lets say i have the following values
month, year, event
1, 1954, flood
1, 1954, flood
2, 1955, tornado
3, 1994, fire
12, 1999, flood
i'm create a bar graph from the values in the db. I'm creating a bar graph on the number of events for each month. now the problem i am running into is this....for the x axis I have the months print out. So for hte above example, Jan would have the value of 2, feb, march, and december would all have 1, and then all the other months would need to have the value of 0. But it's only printing out the months that are in the DB that have values associated with them. The problem is, I need to have ALL the months print out....any ideas on how to do this? Here is some of my code..
$sQuery = "SELECT EventType, month,year, count(EventType) as TotalEventType FROM table WHERE EventType = '$eventtype' and country = '$country' group by month";
$sQuery9 = "select count(EventType) as sum$eventtype from table WHERE DisEventtype = '$eventtype' and country = '$country' group by month order by sum$eventtype desc limit 1";
$rResult9 = mysql_query($sQuery9, $rDatabaseConnection);
$testrow = mysql_result($rResult9,0);
for ($count = 0; $row = mysql_fetch_row($rResult); ++$count)
{
if ($row[1]==1)
{ $newscale = "Jan";
}
else if ($row[1]==2)
{ $newscale = "Feb";
}
else if ($row[1]==3)
{ $newscale = "Mar";
}
else if ($row[1]==4)
{ $newscale = "Apr";
}
else if ($row[1]==5)
{ $newscale = "May";
}
else if ($row[1]==6)
{ $newscale = "Jun";
}
else if ($row[1]==7)
{ $newscale = "Jul";
}
else if ($row[1]==8)
{ $newscale = "Aug";
}
else if ($row[1]==9)
{ $newscale = "Sep";
}
else if ($row[1]==10)
{ $newscale = "Oct";
}
else if ($row[1]==11)
{ $newscale = "Nov";
}
else if ($row[1]==12)
{ $newscale = "Dec";
}
else
{
$newscale = "Undeclared";
}
// };
$imagedata["width"] = 600;
$imagedata["height"] = 400;
$imagedata["caption"] = "$country $eventtype"."s : Number of Occurrences in Record By Month";
$imagedata["xCaption"] = "Month";
$imagedata["xScale"] = 1;
$imagedata["yScale"] = 1;
$imagedata["xValues"] = 1;
$imagedata["yCaption"] = "Number of Events";
$imagedata["yCount"] = $testrow+1;
$imagedata["yMax"] = $testrow+1; //required
$imagedata["yMin"] = 0;
$imagedata["valueCount"] = $count+1;
$imagedata["value$count"] = $row[3];
$imagedata["scale$count"] = "$newscale";
$imagedata["numberFormat"] = "%.0f";
//$id=MakeBarChart($imagedata);
}//;
if ($testrow > 0)
{
$id=MakeBarChart($imagedata);
echo "<img src=getchart.php?id=$id>";