I am trying to use array_walk to convert the date in a databse(mysql) to the day of the week I need it in an array for jpgraph to use as the y axis but am having no luck here is my code.
Thanks
$theday = date("d", time());
$themonth = date("m", time());
$theyear = date("Y", time());
/*== get what weekday the first is on ==*/
$tmpd = getdate(mktime(0,0,0,$themonth,1,$theyear));
$firstday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($themonth,$theyear);
function day($d){
$ans= explode( "-", $d );
return date( 'D' , mktime( 0,0,0, $ans[0], $ans[1], $ans[2] ) ) ;
}
$q = mysql_query("SELECT count(DocketNumber) as amount,Date FROM Production
Where Date >= \"$theyear-$themonth-$firstday 00:00:00\"
AND Date<= \"$theyear-$themonth-$lastday 00:00:00\" group by Date");
$db=mysql_query($q);
$mydata=array();
while($row=mysql_fetch_array($q))
$mydata[]=$row[0];
$mydate[]=$row[1];
$newdate[]=array_walk($mydate,day);
// Create the graph. These two calls are always required
$graph = new Graph(400,200,"Daily Volume");
$graph->img->SetMargin(40,30,20,40);
$graph->SetScale("textlin");
$graph->SetShadow();
// Create a bar pot
$bplot = new BarPlot($mydata);
$bplot->SetFillColor("orange");
$bplot->SetWidth(1);
$graph->Add($bplot);
$graph->title->Set("Daily Volume");
$graph->xaxis->title->Set("Days");
$graph->yaxis->title->Set("Volume");
$graph->xaxis->SetTickLabels($newdate);
$graph->title->SetFont(FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FONT1,FS_BOLD);
// Display the graph
$graph->Stroke();