开发者

Mysql insert and update impressions with PHP

开发者 https://www.devze.com 2023-01-05 06:46 出处:网络
I want to record number of advertisement impressions and clicks per day in database. I\'m using PHP to insert and update that data i开发者_运维技巧n mysql.

I want to record number of advertisement impressions and clicks per day in database. I'm using PHP to insert and update that data i开发者_运维技巧n mysql.

The script that display specific advertisement and store data in db looks like:

...count the number of rows in db with this advertisement ID ...
if ($total == "0") {
mysql_query("INSERT INTO impressions VALUES ('".$id."','1','0',NOW('')");
}else{
mysql_query("UPDATE impressions SET impressions=impressions+1 WHERE id=$id;
}

Table in mysql database:

   id  |   impressions  | clicks  |   date
   ------------------------------------------
    5  |      104       |   23    | 2010-06-23

Can I somehow use limit for the number of impressions per day?

For example if advertiser wants to limit impressions of his add to 5000 per day.

How can I do that?


If you want to put a limit of impression per day, you need to have a place to save that configuration from the advertiser. After that, you only needs to select the adds that is that current impression is inferior than the limit for the current day!

Other thing... you should read something about sql injection and how to prevent that.

I hope my answer help you in any way.

Regards

0

精彩评论

暂无评论...
验证码 换一张
取 消