Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

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

 



On Mon, 3 Aug 2009 11:52:11 +0200, Nisse Engström wrote:

> You could use the date as an index:
> 
>   ... SELECT DATE(`datetimecolumn`) AS `date` ...
> 
>   while ($TrackingRow = mysql_fetch_object (...)) {
>     $data[$TrackingRow['date']] = $TrackingRow;
>     /* Store the last row from each set of dates */
>   }
> 
> or
> 
>   while ($TrackingRow = mysql_fetch_object (...)) {
>     if (!isset ($data[$TrackingRow['date']])) {
>       $data[$TrackingRow['date']] = $TrackingRow;
>     }
>     /* Store the first row from each set of dates */
>   }

And, of course, if you want all rows to be indexed by date:

  while ($TrackingRow = mysql_fetch_object (...)) {
    $data[$TrackingRow['date']][] = $TrackingRow;
  }


/Nisse

-- 
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