Doesn't change status to expired.
<?php
$bannersQuery = 'SELECT * FROM banners WHERE expire > NOW() AND status = "active" ORDER BY RAND() LIMIT 10';
$banners = $db->query($bannersQuery);
while($row = $banners->fetch(PDO::FETCH_ASSOC)){
if($row['expire'] <= time()){
$status = 'expired';
}else{
$status = 'active';
}
$updateQuery = 'UPDATE banners SET exposures = exposures + 1, status = :status WHERE id = :id';
$update = $db->prepare($updateQuery);
$update->bindParam(':status', $status, PDO::PARAM_STR);
$update->bindParam(':id', $row['id'], PDO::PARAM_INT);
$update->execute();
echo '
<a href="index.php?do=bannerClick&id='.$row['id'].'" target="_BLANK"><img src="'.$row['url'].'" width="'.$row['width'].'" height="'.$row['height'].'" alt="'.$row['title'].'"></a><br>';
}
echo '
<a href="index.php?do=buyBanner">Want to advertise your banner? Click here.</a>';
?>