PHP Ad Click Count code

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags advertising click code create default ip network php

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 (' < ', ' &lt; ', $Str);
$temp =str_replace (' > ', ' &gt; ', $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

?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.