Re: arrays & db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why don't you want to do this with SQL?

Ignatius
____________________________________________
----- Original Message -----
From: "Martin Allan Jensen" <bailey@sprit.dk>
To: <php-db@lists.php.net>
Sent: Monday, November 11, 2002 2:48 PM
Subject:  arrays & db


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



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




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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux