I've tried a few things which I thought should've worked but here's my code now:
Expand|Select|Wrap|Line Numbers
- <?
- $bannerquery = "SELECT * FROM banner WHERE active='T' ORDER BY Rand() LIMIT 1";
- $bannerresult = mysql_query($bannerquery);
- while ($brow = mysql_fetch_array($bannerresult)) {
- $bannerid = $brow[0];
- $bannerimage = $brow[2];
- $bannerhref = $brow[1];
- $banneralt = $brow[3];
- $bannerhits = $brow[4];
- if($bannerid != "")
- {
- echo "<a href=\"$bannerhref\" target=\"_blank\"><img src=\"images/banners/$bannerimage\" alt=\"$banneralt\" /></a>";
- /*Update Impressions*/
- $newhits = $bannerhits + 1;
- $bannerinsert = "UPDATE banner SET hits='$newhits' WHERE id='$bannerid'";
- mysql_query($bannerinsert);
- }
- else
- {
- echo "<script type=\"text/javascript\"><!--
- google_ad_client = \"pub-*****************\";
- google_ad_width = 728;
- google_ad_height = 90;
- google_ad_format = \"728x90_as\";
- google_ad_type = \"text_image\";
- google_ad_channel = \"\";
- google_color_border = \"CCCCCC\";
- google_color_bg = \"CCCCCC\";
- google_color_link = \"333333\";
- google_color_text = \"000000\";
- google_color_url = \"333333\";
- //-->
- </script>
- <script type=\"text/javascript\"
- src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
- </script>";
- }
- }
- ?>
Also, is there a simple way of implementing a system to also record how many times it has been clicked (I know it's possible, just not sure how complicated it is)?
Thanks for any help :)