PHP Ads Click Statistics Code, last night there are several IDC network to work with this site to put some ads, but I want to see the effect of advertising after the write a simple advertising statistics code, here is only the statistics can not IP restrictions or nausea click and so on.
To create the database first.
CREATE TABLE IF not EXISTS ' Ad_count ' (
' ad_id ' int (8) not NULL auto_increment,
' Ad_hit ' int (8) Not NULL default ' 0 ',
' ad_name ' varchar character set gb2312 default NULL,
' Ad_datetime ' datetime default NULL,
' AD_QQ ' varchar character set gb2312 default NULL,
' Ad_url ' varchar (900) Character Set gb2312 not NULL,
' Ad_price ' int (8) Not NULL,
PRIMARY KEY (' ad_id ')
) Engine=innodb DEFAULT charset=latin1 auto_increment=4;
Data creation Well, we started writing programs. Data connections I'm not going to write anymore.
<?php
Require_once ("...). Province ");
$ad _id =get_value (' ad_id ', ');
if (Is_numeric ($ad _id)) {
$ad _select= "Select Ad_id,ad_url from Ad_count where ad_id= ' $ad _id ' limit 1";
$ad _update= "Update ad_count set ad_hit=ad_hit+1 where ad_id= ' $ad _id ' limit 1";
$ad _result=mysql_query ($ad _select) or Die (' ID error ');
if (mysql_num_rows ($ad _result)) {
mysql_query ($ad _update);
$ad _rs=mysql_fetch_array ($ad _result);
Header ("Location:". $ad _rs[' Ad_url '));
Mysql_free_result ($ad _rs);
}
}
function htmltohtml ($STR) {
$temp =str_replace (CHR), ' <br/> ', $Str);
$temp =str_replace (' < ', ' < ', $Str);
$temp =str_replace (' > ', ' > ', $Str);
$temp =addslashes ($STR);
return $temp;
}
function Get_value ($value, $para) {
Return htmltohtml (Empty ($para)? Isset ($_get[$value]) $_get[$value]: ':(isset ($_post[$value])? $_post[$value]:
}
Then we'll write the following where we want to display the ads.
' <a href=/cp/ad_count.php?ad_id=2 target=_blank></a>
Is over, the original site, reproduced please indicate the original: www.111cn.net
?>