Wrong logic in If Statement?
- by Charles
$repeat_times = mysql_real_escape_string($repeat_times);
$result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error());
$output .="";
$seconds = time() - strtotime($fetch_array["datetime"]);
if($seconds < 60)
$interval = "$seconds seconds";
else
if($seconds < 3600)
$interval = floor($seconds / 60) . " minutes";
else
if($seconds < 86400)
$interval = floor($seconds / 3600) . " hours";
else
$interval = floor($seconds / 86400) . " days";
while ($fetch_array = mysql_fetch_array($result)) {
$fetch_array["code"] = htmlentities($fetch_array["code"]);
$output .= "<li><a href=\"http://www.***.com/code=" . htmlspecialchars(urlencode($fetch_array["code"])) . "\" target=\"_blank\">" . htmlspecialchars($fetch_array["code"]) . "</a> (" . $interval . ") ago.</li>";
}
$output .="";
return $output;
Why is this returning janice (14461 days) instead of janice (15 minutes ago)
The datetime function table has the DATETIME type in my table so it's returning a full string for the date.