Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?
| From: | Nisse Engström | Date: | Mon, 03 Aug 2009 11:40:27 +0000 |
| Subject: | Re: newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46387@lists.php.net to get a copy of this message | ||
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