abs0lut Posted July 31, 2008 Share Posted July 31, 2008 <?php $querys = mysql_query("SELECT expirydate FROM polls"); while($row = mysql_fetch_array($querys)) { $expiry_date=$row['expirydate']; } $datetoday= date("Y-m-d"); function datecheck($date1,$date2) { $date1_array = explode("-",$date1); $date2_array = explode("-",$date2); $now = mktime(0,0,0,$date1_array[1],$date1_array[2],$date1_array[0]); $expiration = mktime(0,0,0,$date2_array[1],$date2_array[2],$date2_array[0]); if ($now>$expiration) { $query = mysql_query("SELECT checked FROM polls") or die (mysql_error()); while($row = mysql_fetch_array($query)) { $check=$row['checked']; } if($check!='yes'){ $result = mysql_query("UPDATE polls SET status='expired'") or die(mysql_error()); } } } datecheck($datetoday,$expiry_date); ?> For every poll I need to check if now is greater than expiration date.. It will set expired to yes for every poll, if the date now is greater than the expiration date and checked is not equal to no. Link to comment https://forums.phpfreaks.com/topic/117444-solved-update-for-every-poll/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.