Please help if you can, I am trying a function to display an icon in a table of user-submitted URLs over the past 3 weeks, but with a "new" .gif if the entry(s) occured in the last 7 days. Basically, I am trying to compare the timestamp in the database entry with the current time minus 7 days. Here's the code I'm using:
function checkNew() {
$days = 7;
$label = "<img src=\"../../images/ico_new.gif\" alt=\"New in the last 21 days!\" border=\"0\" width=\"32\" height=\"12\">";
$none = " ";
$newDefinition = (time() - (86400 * $days)); // 7 days
if ($ent <= $newDefinition) {
return $none;
} else {
return $label;
}
}
mysql_connect("$DBHost","$DBUser","$DBPass");
$result=mysql("$DBName","SELECT address, urlID, section, entry_time FROM extURL WHERE TO_DAYS(NOW()) - TO_DAYS(entry_time) < 21");
while ($Nrow = mysql_fetch_row($result)) {
$Nurl=$Nrow[0];
$Nnum=$Nrow[1];
$Nsec=$Nrow[2];
$Ntim=$Nrow[3];
$ent = explode(",", $Ntim); {
for ($i = 0; $i < $ent; $i++);
$show = checkNew($ent[timestamp]);
}
$pieces=explode(":",$Ntim);
if ( ereg( "([0-9]{4})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})", $Ntim, $regs ) );
if ($Nnum != "")
echo "\n<td valign='top'>\n$show <a href=\"$Nurl\" target=\"_blank\"><b>$Nurl</b></a></td>\n<td valign='top'>$Nsec</td>";
echo "\n<td align='left'>$regs[2]/$regs[3]/$regs[1] $regs[4]:$regs[5]:$regs[6]</td>\n</tr>";
}
echo "\n</table>\n";
Thanks to all who can help, sorry for such a basic question, but sometimes it seems I have the most trouble with basic stuff ;-(
--ph