my problem is this..
i have a mysql database i am getting values from...lets say i have month, and a number
so
month, number
1, 4
2, 4
3, 2
4, 5
8, 4
now, i want to have it so i can print out the months in order , even if they are not in the database, with a value of 0 if they are not. so i want it to print out like this
1,4
2,4
3,2
4,5
5,0
6,0
7,0
8,4
9,0
10,0
11,0
12,0
how would i go about doing this? I'm simplifying my code...here is an example
(i'm using \it to create a bar chart)
$sQuery = "SELECT DisType, month,year, count(DisType) as TotalDisType FROM table WHERE DisType = '$eventtype' and country = '$country' group by month";
$rResult=($sQuery,$linkID);
for ($count = 1; $count < 14; ++$count)
{
$row = mysql_fetch_row($rResult);
//
if (in_array ($row[1], $montharray))
{
$newvalue = $row[3];
echo "test $newvalue<br>";
}
else
{
$newvalue = 0;
echo "ZERO VALUE $newvalue<Br>";
}
//
// $newnumber = $row[3];
if ($count==1)
{
$newscale = "Jan";
}
else if ($count==2)
{ $newscale = "Feb";
}
else if ($count==3)
{ $newscale = "Mar";
}
else if ($count==4)
{ $newscale = "Apr";
}
else if ($count==5)
{ $newscale = "May";
}
else if ($count==6)
{ $newscale = "Jun";
}
else if ($count==7)
{ $newscale = "Jul";
}
else if ($count==8)
{ $newscale = "Aug";
}
else if ($count==9)
{ $newscale = "Sep";
}
else if ($count==10)
{ $newscale = "Oct";
}
else if ($count==11)
{ $newscale = "Nov";
}
else if ($count==12)
{ $newscale = "Dec";
}
else if ($count==13)
{
$newscale = "Und";
}
else
{}
// };
$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"] = $newvalue;
$imagedata["scale$count"] = "$newscale";
$imagedata["numberFormat"] = "%.0f";
//$id=MakeBarChart($imagedata);
}//;
if ($testrow > 0)
{
$id=MakeBarChart($imagedata);
echo "<img src=getchart.php?id=$id>";
}