On 05-Feb-2001 Steve Werby wrote:
> <[EMAIL PROTECTED]> wrote:
>>         suppose i have a multidimensional array ex:
>>
>>         row[monthnr][daynr][hour][numberofusers]
>>         row[monthnr][daynr][hour][numberofmails]
>>         row[monthnr][daynr][hour][numberofdownloads]
>>
>>         the values in the array are a sql result query, soh not all of
> them are
>> filled like it is possible that row[12][1][23] is undefined.
>>
>>         i need to tag the value that is maximum and minimum foreach number
> of
>> users, numberof mails and numberofdownloads in the same month for example,
> i
> 
> You might want to try to get this info directly from an SQL query.  It'll
> probably be much faster than a PHP solution involving looping through each
> available month and finding the max and min for 3 different keys.  If you
> decide to do this you'll probably want to nest "while ( list( $key, $val ) =
> each( $row[$i][number..] )" type statements, but given that the key "hour"
> isn't really needed you may have to transform your array and I really don't
> think this solution is as elegant as using a database query.
> 
> SELECT month,
>                MAX(numberofusers) AS numberofusers_max,
>                MIN(numberofusers) AS numberofusers_min,
>                ...,
>                MIN(numberofdownloads) AS numberofdownloads_min
> FROM my_table
> GROUP BY month
> WHERE where_clause;
> 
> --
> Steve Werby
> COO
> 24-7 Computer Services, LLC
> Tel: 804.817.2470
> http://www.247computing.com/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

i thought about that, but i gave up on my first attempt on doing so, because
mysql complained about my query, it seems that it doesn't allow to use the
max() function with a sum() function, an example of the query is:

SELECT month,
       daynr,
       hour,
       sum(numberofusers),
       sum(numberofmails),
       sum(numberofdownloads)
FROM table
GOURP BY month, daynr, hour
WHERE where_clause;

and mysql complaints when i do another column with max(sum(numberofusers)) :\

i think i'm doomed with the big loop thing :\

               Rui Barreiros
          Software Developer

WEBSOLUT - Soluções Internet
Emailto: [EMAIL PROTECTED] 
Personal Info: http://websolut.net/people/rui.html

As informações contidas neste email são confidenciais
e destinam-se apenas à(s) pessoa(s) a quem foi enviado:
http://websolut.net/confidencialidade-responsabilidade.html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to