RE: [PHP-DB] array with two dimensions

From: Date: Mon, 17 Feb 2003 16:37:38 +0000
Subject: RE: [PHP-DB] array with two dimensions
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-25691@lists.php.net to get a copy of this message
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:bailey@sprit.dk] Sent: February 17, 2003 8:28 AM To: php-db@lists.php.net 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)

« previous php.db (#25691) next »