Hi there,
I have written an array of data so that it json_encodes into the correct format required for a charting component that I am using. The php array looks like this:
First Number = hours
Second Number = data
$menu['metric1'] = array(
label => "Metric 1",
data => array(
array ('00',48),
array ('01',47),
array ('02',45),
array ('03',40),
array ('04',42),
array ('05',48),
array ('06',38),
array ('07',28),
array ('08',40),
array ('09',30),
array ('10',38),
array ('11',28),
array ('12',18),
)
);
$menu['metric2'] = array(
label => "Metric 2",
data => array(
array ('00',30),
array ('01',44),
array ('02',35),
array ('03',49),
array ('04',32),
array ('05',47),
array ('06',38),
array ('07',23),
array ('08',30),
array ('09',34),
array ('10',38),
array ('11',20),
array ('12',31),
)
);
When I json encode this, it is represented as this which is perfect.
{
"metric1": {
"label":"Metric 1",
"data":[["00",48],["01",47],["02",45],["03",40],["04",42],["05",48],["06",38],["07",28],["08",40],["09",30],["10",38],["11",28],["12",18]]
},
"metric2": {
"label":"Metric 2",
"data":[["00",30],["01",44],["02",35],["03",49],["04",32],["05",47],["06",38],["07",23],["08",30],["09",34],["10",38],["11",20],["12",31]]
}
}
What I am trying to do now is to create that php array from a database, so I have loaded the data into my DB, I have run the correct select statement to extract my data . . . . . and this is where I am now stuck.
How would I code up my db result set to form my multidimensional array?????
Any help would be greatly appreciated . . . .going a little mad trying to figure this out.
Cheers
Jon