<?php
$result = dbquery("SELECT * FROM `".$db_prefix."banner` WHERE `status`='1' ORDER by RAND() LIMIT 3");
while ($data = dbarray($result)) {
echo "<td><a href='/reklama-".$data['bid']."/' target='_blank'><img src='".$data['imageurl']."' border='0' height='60' width='468'></a></td>";
$kiek = $data['impmade'] + 1;
dbquery("UPDATE `".$db_prefix."banner` set impmade='$kiek' WHERE bid='".$data['bid']."'");
if($data['impmade'] >= $data['imptotal'] && $data['imptotal']!='0') {
dbquery("UPDATE `".$db_prefix."banner` SET `enddate`='NOW( )',`status`='0' WHERE `bid`='".$data['bid']."'");
}
}
?>