Page is a not externally linkable
rocknbil - 4:32 pm on May 9, 2011 (gmt 0)
What should do it? I think that I am lost.
I have a field that is datetime (mysql) and I am trying to pull the data from that table that is within the last 7 days (PHP).
Substitute "datefield" for whatever that field is named and "table" for the name of the table.
select * from table where datefield >= date_sub(curdate(), interval 7 day);
In PHP, that would be something like
$query = "select * from table where datefield >= date_sub(curdate(), interval 7 day)";
$result = mysql_query($query) or die("Cannot get last 7 days: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
// Row data is stored in $row, whatever the field names are . . . .
echo "<p>ID: " . $row['id'] . " date: " . $row['datefield'] . "</p>";
}