I need to store three pieces of data - a result of a SQL query - in a multidimensiona l array, but don't really succeed. Sometimes it works, but then the output doesn't work accordingly.
My SQL result comes with something like this:
Expand|Select|Wrap|Line Numbers
- Africa | y2000 | 9430
- Africa | y2005 | 9678
- Europe | y2000 | 2314
Last thing I came up with was this for stocking the data in the array:
[PHP]$sum_pop_total_ dataset[] = array($row['reg_name'] => array($row['year'], $row['popt']));[/PHP]
That seemed to work. But then the output function went a bit wrong:
[PHP]while (list($key1) = each ($sum_pop_total _dataset))
{
echo "<br />key1: ".$key1;
while (list($key2, $value) = each ($sum_pop_total _dataset[$key1]))
{
echo "<br />key2: ".$key2." value: ".$value[0];
}
}[/PHP]
[HTML]key1: 0
key2: North America value: y_2005
key1: 1
key2: Europe value: y_2005
key1: 2
key2: Asia + Pacific value: y_2005[/HTML]
So, it seemed that the allocation of the SQL result to the principal variable didn't work correctly. But if I take the [] away from $sum_pop_total_ dataset[]*= ..., than the variable is being re-initialized at each time.
Can someone give me a hint what I should do?
Thanks a lot!