There are really a few ways that you can solve this problem. I would use
and associative array to do this. 

Making the array associative would work like this:
$ALL_VALUES["$year"] += $value;

To retrieve the information back you would use the following loop:

While($element = each($ALL_VALUES))
{
        echo $element[ "key" ]; //this would display the year
        echo $element[ "value" ]; //displays the value associated with
the year

}

Hope that helps, I have tested it and it works for me

Kelly Protsko


-----Original Message-----
From: Lars Rasmussen [mailto:[EMAIL PROTECTED]] 
Sent: February 17, 2003 8:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] array with two dimensions

Hi all,
 
Got a little problem here,
 
I have a mysql query that looks like this
SELECT SUM(value) as value, YEAR(dileveret) as year FROM table GROUP BY
YEAR(dileveret)
 
It works just fine, but i need to make a array that can could do
somthing like this (know it doesent work)
$ALL_VALUES[$year] += $value;
 
The script is running the script up to 100 times to get all the specific
data's, i hope that you know a way that i can hold the values, and year
and later print one value for each year..
 
THANKS A LOT!
 
Regards
Lasse (newbie)



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to