3v4l.org

run code in 300+ PHP versions simultaneously
<?php require("db.php"); mysql_connect($DBserver, $DBuser, $DBpass) or die(mysql_error()); mysql_select_db($DBname) or die(mysql_error()); // Get data from the "CRFAds" table $result = mysql_query("SELECT * FROM CRFAds WHERE SubmitterName Like 'David%'") or die(mysql_error()); // Keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { //Get Ad Start Date $AdStartDate = date("F d, Y",strtotime($row['StartDate'])); //Check to see if it is either new (expires in 90 days) or a renewal (expires in 120 days) If ($row['NewOrRenewal']=="Renewal") { $AdExpirationDate = date("F d, Y",strtotime($row['StartDate'] . '+120 days')); //Calculate the difference between expiration date and today to see if it expires within 30 days $today = date("F d, Y"); $DayDiff = abs(strtotime($AdExpirationDate) - strtotime($today)); $DaysToExpiration = floor(($DayDiff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if ($DaysToExpiration <= 30) { $Expire30 = "Yes"; }else{ $Expire30 = "No"; } }else{ $AdExpirationDate = date("F d, Y",strtotime($row['StartDate'] . '+90 days')); //Calculate the difference between expiration date and today to see if it expires within 30 days $today = date("F d, Y"); $DayDiff1 = abs(strtotime($AdExpirationDate) - strtotime($today)); $DaysToExpiration = floor(($DayDiff1- $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if ($DaysToExpiration <= 30) { $Expire30 = "Yes"; }else{ $Expire30 = "No"; } } //Calculate the difference between today and start date to see if it is new within the last 30 days $DayDiff2 = abs(strtotime($AdStartDate) - strtotime($today)); $DaysRunning = floor(($DayDiff2- $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if ($DaysRunning <= 30) { $New30 = "Yes"; }else{ $New30 = "No"; } } ?>

preferences:
40.31 ms | 402 KiB | 5 Q