arrays & db
| From: | Martin Allan Jensen | Date: | Mon, 11 Nov 2002 13:48:24 +0000 |
| Subject: | arrays & db | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-23211@lists.php.net to get a copy of this message | ||
Okey people, i try again....!!
I have a table in a mysql database that holds this:
+----+--------+------------+--------+------+
| id | maaler | aflaest | vaerdi | pris |
+----+--------+------------+--------+------+
| 21 | 11 | 2002-01-01 | 15160 | 0.00 |
| 22 | 11 | 2002-02-01 | 15180 | 0.00 |
| 23 | 11 | 2002-03-01 | 15200 | 0.00 |
| 24 | 11 | 2002-04-01 | 15240 | 0.00 |
| 25 | 11 | 2002-05-01 | 15250 | 0.00 |
| 27 | 10 | 2002-11-14 | 210 | 0.00 |
| 30 | 10 | 2002-12-19 | 230 | 0.00 |
+----+--------+------------+--------+------+
Each "maaler" have it's own start registration witch is:
+----+----------+-------+
| id | nummer | start |
+----+----------+-------+
| 10 | 56456 | 200 |
| 11 | 000002 | 15150 |
+----+----------+-------+
I then made a script that takes "start" for each "maaler" if it have any
registrations. Then it does this:
if its first field then it takes the "vaerdi"(THE VALUE) and - it with the
"start" (THE STARTREGISTRATION) For the next fields it takes the "vaerdi" - the
last "vaerdi". My problem is that after the script has ran it have lets say 20 yeas 2002
(the registration year called "aflaest" in the table) and lets say two 2003. I only need
ONE value "vaerdi" per year, witch is the one it just calculated in a loop. But it have
all the values and years in the array. How do i only take ONE value per year in PHP NOT SQL??
I really hope this is discriping enough....!!
THANKS ALL!
Martin Allan Jensen