Only show image if expire data??
Posted: Sun Jun 22, 2008 5:04 am
I'm making this fairly simple script, but can't seem to make it work! All images has an expire date like this:
db field (expires)
2009-06-11 00:00:00
I then want to show the image if the date hasnt expired current date. This I try to achive like this:
My $time is (22-06-2008)
I then have 2 records in my db with expires dates like this:
Record 1. 11-06-2009
Record 2. 20-06-2008
Now I would like to make the script show the expires date on record 1 and "EXPIRED!" at record 2.
What happens now is that it shows both with the expires date?!?!?
If I use this operator "<=" it shows both as "EXPIRED!"?!?!
Where do I go wrong? Please help
db field (expires)
2009-06-11 00:00:00
I then want to show the image if the date hasnt expired current date. This I try to achive like this:
Code: Select all
$time = date('d-m-Y');
$result = mysql_query("SELECT *,DATE_FORMAT(expires, '%d-%m%-%Y') AS expires FROM sponsor WHERE uid='".$uid."'");
while($row = mysql_fetch_array($result)) {
echo '<table width="320" border="0" cellspacing="0" cellpadding="0"><tr>';
if ($time >= $row['expires']) {
echo '<td><div align="left" style="padding-top:5px;">Hits: '.$row['hits'].' | Expires: '.$row['expires'].' | current date: '.$time.'</div></td>'; }
elseif ($time < $row['expires']) {
echo '<td><div align="left" style="padding-top:5px;">Hits: '.$row['hits'].' | Expires: <r>EXPIRED!</r></div></td>'; }
echo '</tr></table><br>';
}I then have 2 records in my db with expires dates like this:
Record 1. 11-06-2009
Record 2. 20-06-2008
Now I would like to make the script show the expires date on record 1 and "EXPIRED!" at record 2.
What happens now is that it shows both with the expires date?!?!?
If I use this operator "<=" it shows both as "EXPIRED!"?!?!
Where do I go wrong? Please help