Page 1 of 1

Counting Banner Views

Posted: Mon Sep 30, 2002 6:11 pm
by sinewave
I'm not really searching for code so much as logic. What i want to do is create a simple banner management system, which will store in a database the number of page views and number of clicks.

What would be the easiest/most efficient way to keep this in a database, i want to be able to do this weekly/daily/monthly or whatever...meaning 100 views this month, 15 clicks this month.

i'm just trying to figure out in my head how the heck to start this...any advice would be great.

Posted: Tue Oct 01, 2002 10:04 am
by Takuma
Have a img code like this

Code: Select all

<a href="jump.php?bannerid=<?php echo $id ?>"><img src="banner.jpg"></a>
and the have PHP code like

Code: Select all

<?php
mysql_connect("","","");
mysq_select_db("");

$sql = "SELECT count FROM banners WHERE id = {$_GETї'id']}";
list($result) = mysql_fetch_array(mysql_query($sql));
$result++;
$sql = "UPDATE banners set count = $result WHERE id = {$_GETї'id']}";
mysql_query($sql);

//Then jump to the URL
?>

Posted: Tue Oct 01, 2002 11:45 am
by sinewave
I can see how that would be great for total clicks, would the easiest way to do it weekly be...have another table and a cron for every sunday night or something, where it moves that total to the new table and puts 0 in the old one.