[UPHPU] find latest date
Brent Wilkinson
brent at air2data.com
Wed Aug 25 21:29:25 MDT 2004
Use the orderby and then use mysql_num_rows in php. It returns the numbers
of rows collected. If you get 6 rows then parse the first row. All you need
to do is remove the limit 1. Then you know the first row is the one you
want.
<?php
$query='select * from database ORDERBY datetime ASC';
$result=mysql_query($query);
If(mysql_num_rows($result) = 6)
{
$row=mysql_fetch_assoc($result);
$data=$row['datetime'];
}
?>
Just a quick example
Brent Wilkinson
Tech Manager
Air2Data
(866)-779-8585
(801)-510-7474
-----Original Message-----
From: Wade Preston Shearer [mailto:groups at anavidesign.com]
Sent: Wednesday, August 25, 2004 9:01 PM
To: list at uphpu.org
Subject: Re: [UPHPU] find latest date
> To just get the one you want:
>
> ORDERBY datetime ASC/DESC LIMIT 1
This should work (thanks Jeremy and Steve), but I do have one more
question...
To be more specific, what I really need is to retrieve the latest date ONLY
if there is a date for all site fields. So, would I have to retrieve them
all instead and verify that the six strings were not empty first, or is
there a way to test for empty fields with MySQL in the query?
---------------------------------------------------------------------
To unsubscribe, e-mail: list-unsubscribe at uphpu.org For additional commands,
e-mail: list-help at uphpu.org
More information about the UPHPU
mailing list