Hi all,
I'm having a tough time trying to get this date issue right.
I have a mysql table that contains a str_date column. The column has a DATE type associated to it.
What i am trying to do is set up a query that will only display those rows in the table that are 5 days old. If they are older than that they do not get displayed.
This is what i have so far (i'm not even sure to whether or not i should do two queries):
<?php
include ('include/dbconnect.php');
$sql = mysql_query("SELECT str_date FROM contacts");
while ($row = mysql_fetch_array ($sql)) {
$str_date = strtotime($row['str_date']);
$future_date = $str_date+432000; //432000 = 5 days
if ($future_date >= $str_date){
$qr = mysql_query("SELECT contactID,name_Last1,name_First1,fire_text1 from contacts WHERE str_date <= '".$future_date."'");
$r_string = 'n='.mysql_num_rows ($qr);
$i = 0;
while ($row = mysql_fetch_assoc ($qr)) {
while (list ($key, $val) = each ($row)) {
$r_string .= '&' . $key . $i . '=' . $val ;
}
$i++;
}
}
}
// without extra &, this is returning extra chars at the end
echo $r_string.'&';
?>
Any ideas?
Cheers,
micmac