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.
First, create the database.
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 ', '): Here's a talk
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 ');
&NBSP;&NBSP
if (mysql_num_rows ($ad _result)) {
&NBSP
mysql_query ($ad _update);
&NBSP;&NBSP
$ad _rs=mysql_fetch_array ($ad _result);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP
header ("Location:". $ad _rs[' Ad_url ']);
mysql_free_result ($ad _rs);
&NBSP;&NBSP}
}
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><img src=/ad_a/ad2.gif border=0/></a>
Is over, the original site, reproduced please indicate the original: www.jzread.com
?>