there is a code bbcode for showing coding....please use it.
btw yours is the same as the one above, both use hard coded arrays....must i do everything?
banclick.php
<?php
session_start();
$q=mysql_query("SELECT * FROM banners WHERE bMAXCLICKS>bCLICKS AND bACTIVE=1 AND bID=".$_GET['ID'].");
if(mysql_num_rows($q) == 0)
{ die("Advert doesn't exist."); }
$r=mysql_fetch_array($q);
if($_SESSION['adclick'] == 0) {
query("UPDATE banners SET bCLICKS=bCLICKS+'1' WHERE bID='{$_GET['ID']}'");
$_SESSION['adclick']=$_GET['ID'];
}
header("Location:".$r['bURL']);
?>
display banners
<?php
$q=mysql_query("SELECT * FROM banners WHERE bMAXCLICKS>bCLICKS AND bACTIVE=1 ORDER BY rand() LIMIT 1");
if(mysql_num_rows($q))
{
$r=mysql_fetch_array($q);
query("UPDATE banners SET bVIEWS=bVIEWS+'1' WHERE bID={$r['bID']}");
print "<center><table width='468'>
<tr>
<td><a href='banclick.php?ID={$r['bID']}' border='0'>
<div align='center'>
<img width='468' height='60' src='{$r['bIMAGE']}' border='0'>
</div>
</a></td>
</tr>
</table>
</center>";
}
?>
SQL for banner table
DROP TABLE IF EXISTS `banners`;
CREATE TABLE `banners` (
`bID` int(11) NOT NULL auto_increment,
`bURL` varchar(255) NOT NULL default '',
`bIMAGE` varchar(255) NOT NULL default '',
`bACTIVE` int(11) NOT NULL default '0',
`bCLICKS` int(11) NOT NULL default '0',
`bVIEWS` int(11) NOT NULL default '0',
`bMAXCLICKS` int(11) NOT NULL default '0',
`bFROM` int(11) NOT NULL default '0',
PRIMARY KEY (`bID`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;