Forum Moderators: coopster
BACKGROUND:
Create data arrays for graph plots
WHAT WORKS:
The SQL portion, the creation of master array-> from which I chose data array per unique category:
$plot=array();while ($row=mysql_fetch_assoc($result)) {
$time['time'] =( $row['time']);
$prio['Priority'] = ($row['Priority']);
$valu['total'] =( $row['total']);
//creating arrays
if(!is_array($plot[$prio['Priority']]))
{
$plot[$prio['Priority']] = array();
}
array_push($plot[$prio['Priority']], $valu['total']);
}
DATA DUMP AFTER THIS STEP:
array(4) { ["1 - Started within one hour"]=> array(4) { [0]=> string(2) "59" [1]=> string(2) "72" [2]=> string(2) "45" [3]=> string(2) "19" } ["2 - Started within four hours"]=> array(4) { [0]=> string(3) "118" [1]=> string(2) "77" [2]=> string(3) "107" [3]=> string(2) "58" } ["3 - Started within 24 hours"]=> array(4) { [0]=> string(2) "47" [1]=> string(2) "48" [2]=> string(2) "38" [3]=> string(2) "17" } ["4 - As soon as possible"]=> array(2) { [0]=> string(2) "19" [1]=> string(2) "15" } }
PASSING DATA:
$g1=array_pad($plot['1 - Started within one hour'],4,0);
$g2=array_pad($plot['2 - Started within four hours'],4,0);
$g3=array_pad($plot['3 - Started within 24 hours'],4,0);
$g4=array_pad($plot['4 - As soon as possible'],4,0);
DATA DUMP AFTER THIS:
array(4) { [0]=> string(2) "59" [1]=> string(2) "72" [2]=> string(2) "45" [3]=> string(2) "19" }
array(4) { [0]=> string(3) "118" [1]=> string(2) "77" [2]=> string(3) "107" [3]=> string(2) "58" }
****PROBLEM****
When I pass this $g1, I get the error "UNDEFINED INDEX:'1 - Started within one hour'"
WHAT I NEED:
Can any one tell me if my array construct is right or wrong (I am a newbie myself in PHP)...or am I passing the data values wrong?
TIA
$array[] =
//creating arrays
if(!is_array($plot[$prio['Priority']]))
{
$plot[$prio['Priority']] = array();
}
array_push($plot[$prio['Priority']], $valu['total']);
}
$plot[$prio['Priority']][] = $valu['total'];and see if your problem is cleared up.