Page 1 of 1

find php group by using an array

Posted: Fri Mar 11, 2011 7:08 am
by vishnu22_7
I have the php array like this:

Code: Select all

Array
(
    [0] => Array
        (            
            [time_stamp] => 1287484988
            [date_time] => Tuesday, 19 October 2010 16:13:7
            [day] => 19
            [month] => 10
            [year] => 2010
            [time_spent] => 41
        )

    [1] => Array
        (         
            [time_stamp] => 1287484662
            [date_time] => Tuesday, 19 October 2010 16:7:41
            [day] => 19
            [month] => 10
            [year] => 2010
            [time_spent] => 215           
        )
)
I calculated the number of days in a given month like this:

Code: Select all

$num_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);   
How do i loop through the "$num_days" to calculate the SUM of time_spent using GROUP BY time_stamp where day=$day,month=$month,year=$year

Thank u.

Re: find php group by using an array

Posted: Fri Mar 11, 2011 3:58 pm
by social_experiment

Code: Select all

<?php
print_r($num_days);
?>
What is echoed to the browser when you do this?

Re: find php group by using an array

Posted: Fri Mar 11, 2011 9:53 pm
by vishnu22_7
$num_days is total number of days in a goven month: for Jan, it is 31