Counting Banner Views

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

Counting Banner Views

Post 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.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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
?>
sinewave
Forum Commoner
Posts: 41
Joined: Tue Sep 10, 2002 4:35 pm
Location: Canada

Post 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.
Post Reply