Home >php教程 >PHP源码 >php 广告点击统计代码

php 广告点击统计代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:30:311165browse
<script>ec(2);</script>

php 广告点击统计代码,昨天晚上有几个IDC网想与本站合作放些广告,但是我想看看广告效果后想了就写了一个简单的广告统计代码了,这里只是等的统计不能IP限制或是恶心点击等等了.

先来创建数据库.

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(200) character set gb2312 default NULL,
  `ad_datetime` datetime default NULL,
  `ad_qq` varchar(15) 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 ;

数据创建好了我们就开始写程序了.数据连接我不不写了,

 require_once("......省了");
 $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(13),'
',$Str);
  $temp =str_replace('   $temp =addslashes($Str);
  return $temp;
 }
 function get_value($value,$para){ 
  return htmltohtml(empty($para)?(isset($_GET[$value])?$_GET[$value]:''):(isset($_POST[$value])?$_POST[$value]:''));
 }

然后我们再在要显示广告的地方如下写.

'php 广告点击统计代码

就完了了,本站原创,转载请注明来原:  www.111cn.net
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn