RE: Matching arrays to build tables

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

 



Just a question for the purpose of giving a proper answer:
is it possible to have different codes on the very same day? 

-----Original Message-----
From: Mike Quinn
To: php-windows@lists.php.net
Sent: 29-9-2003 7:11
Subject: Re:  Matching arrays to build tables

Hi Svensson,

Thanks for that.  (I can certainly use that to get the values for the
added
amounts for me) but I wish for the table to be built with 15 days in the
left hand column some of which will not contain entries but for the days
that there are items I wish for the HTML table to display these beside
the
correct date of entry.  I have no quams with SQL but with arrays in PHP.
I
guess what I have to do is loop from 1 to 15 using $i to display all of
the
days in left column, then within the loop check the value $i to see if
it is
equal to $days[] if it is then add the values for this day and pop it
into a
column beside the day and then the code next to this.  I have tried what
I
believe to be the best way to do this but have failed miserably as I am
crap
with array manipulation.

Thanks a mil for the SQL though,

Michael


"B.A.T. Svensson" <B.A.T.Svensson@lumc.nl> escribio en el mensaje
D291F33C586C8E48B95C26F8C805513A319B94@mail5.lumc.nl">news:D291F33C586C8E48B95C26F8C805513A319B94@mail5.lumc.nl...
> Would something like
>
> SELECT day, SUM(amount) AS amount_sum, DISTINCT(code) AS code
> FROM <some tables>
> WHERE <some conditions are true>
> GROUP BY day,amount _sum, Code
>
> be usefull for you? Or do you already do this?
>
> -----Original Message-----
> From: Mike Quinn
> To: php-windows@lists.php.net
> Sent: 29-9-2003 6:30
> Subject:  Matching arrays to build tables
>
> Hi,
>
> I have 3 dynamic arrays which is related data pulled from a mySQL
> database,
> the first being day $days[],second being amount $amount[] and third
> being a
> specific code $code[]. What I need to do is display a table with 1 to
15
> in
> the left hand column (days) but where the array $days[] contains an
item
> I
> need to add a column with the related data but add the values of
amount
> if
> there are two entries for a given day, something like the below.
>
> $days[] = ('2', '2', '5');
> $amount[] = ('150', '100', '90');
> $code[] = ('LAC', 'LAC', 'NCA');
>
> +++++++++++++
> Day |Amt. | Code |
>  1    |  0     |           |
>  2    |  250 | LAC  |
>  3    |  90   | NCA |
>  4    |  0     |           |
>
> etc. until 15!
>
> Any help would be greatly appreciated my code is getting jumbled and
> confusing :(.
>
> Thanks
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux