I have a mysql database with a user generated date from the html5 form element “date”(or 2013-01-06 if their browser doesn’t support html5). I’m looking to select and output dates only after 3 days have passed.
I’ve looked around stack overflow and found a few threads that looked promising and came up with(table = files1, date column = datec):
$query = "SELECT * FROM files1 WHERE DATEDIFF(day, now(), datec) >3";
$result = mysql_query($query,$con);
echo $result;
while($row = mysql_fetch_assoc($result)){
foreach($row as $name => $value){
echo "$name: $value\t";
}//end foreach
}//end while
However this produces:
“Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given” which I’ve found to come from the query not executing.
If you have a create/date column in your table you could select by that using date_add
Try DATE_ADD
but to use datediff: