澳门新葡亰平台游戏网站php计数器的设计与实现

本程序有4个计数器。
index.php是一个普通的计数器可以看出总次数和哪个人来这个站点的次数,点几次加几次,不防水。
index1.php也是一个防水的计数器可以看出次数和哪个人来这个站点的次数,点几次加几次,防水,5秒加一次。
index2.php是一个防水的计数器可以看出总次数和哪个人来这个站点的次数,点几次加几次,防水,2秒加一次。
indexa.php是一个普通和防水和图形的计数器3合一的。可以看出总次数和哪个人来这个站点的次数,防水,有图形。
关键语句:
防水的:$sql=”SELECTCOUNT(*)FROM`counter_1`WHEREuser=’$user’ANDTIME_TO_SEC(NOW()-`time`)5ANDip=’$REMOTE_ADDR'”;
图形计数器:for($i=0;$istrlen($row[0]);$i++) {
$digit=substr($row[0],$i,1);
$pic.=”imgsrc=/”timex/$digit.gif/”width=/”15/”height=/”20/””; }

<?php
     
      php 留言板防刷新效果       $ip = $_SERVER[‘REMOTE_ADDR’];
      $conn = mysql_connect($mysql_server_name, $mysql_username,
$mysql_password);
      $sql = “SELECT * FROM `my_counter` WHERE ip = ‘$ip'”;
      mysql_select_db($mysql_database, $conn);
      $result = mysql_query($sql);
      $row = mysql_fetch_row($result);
      print_r($row);
     
      if(!$row)   //如果IP没有出现过就新增
      {
       $sql = “INSERT INTO `my_counter` ( `new`, `ip`,
`time_at`) VALUES (‘1’, ‘$ip’, NOW())”;
       $result = mysql_query($sql);
      }
      else        //如果IP出现过
      {
       $sql = “SELECT TIME_TO_SEC( NOW( ) ) – TIME_TO_SEC( time_at
) FROM `my_counter` WHERE `ip` = ‘$ip’ORDER BY `TIME_TO_SEC(
NOW( ) ) – TIME_TO_SEC( time_at )` ASC “;
       $result = mysql_query($sql);
       $row = mysql_fetch_row($result);
       print_r($row);
      
       if($row[0]>5)   //如果IP出现过,则看他有没有超过5秒
       {
         $sql = “INSERT INTO `my_counter` ( `new`, `ip`,
`time_at`) VALUES (‘1’, ‘$ip’, NOW())”;
         $result = mysql_query($sql);
       }
      }
     
       $sql = “SELECT COUNT(*) FROM `my_counter`”;
       $result = mysql_query($sql);
       $row = mysql_fetch_row($result);
       print_r($row);
       mysql_free_result($result);
       mysql_close($conn);
?>

?//——[ 基本设定 ]——-$mysql_server_name =
“localhost”;$mysql_username = “root”;$mysql_password =
“512783”;$mysql_database = “jishuqi”;//——-//准备好你的sql$sql =
“INSERT INTO `counter_1` ( `user` , `ip` , `time` ) VALUES
(‘$user’, ‘$ip’, NOW( ) );”;$conn=mysql_connect( $mysql_server_name,
$mysql_username,
$mysql_password);mysql_select_db($mysql_database,$conn);$result =
mysql_query($sql);//$id = mysql_insert_id();mysql_close($conn);

//建立连接——通过$conn=mysql_connect( $mysql_server_name,
$mysql_username, $mysql_password );

//准备好你的SQL语法$sql = “SELECT COUNT(*) FROM
`counter_1`”;//进行查询$result=mysql_db_query( $mysql_database,
$sql,$conn );//将查询后的结果–抓出一笔$row1=mysql_fetch_row($result);

//印出该笔资料的所有栏位的阵列//print_r($row1);//清除查询结果mysql_free_result($result);

//建立连接——通过$conn=mysql_connect( $mysql_server_name,
$mysql_username, $mysql_password );

//准备好你的SQL语法$sql = “SELECT COUNT(*) FROM `counter_1` WHERE
user=’$user'”;//进行查询$result=mysql_db_query( $mysql_database,
$sql,$conn );//将查询后的结果–抓出一笔$row2=mysql_fetch_row($result);

//印出该笔资料的所有栏位的阵列//print_r($row2);//清除查询结果mysql_free_result($result);?

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“”htmlheadmeta “Content-Type” content=”text/html;
charset=gb2312″title3种计数器/titlestyle type=”text/css”!–.style1
{font-size: 24px;color: #00FF99;}.style2 {color: #FF00FF}.style3
{color: #CC0033}.style4 {color: #0000FF}.style5 {color:
#FF0000}.style6 {font-size: 36px;color: #996633;}–/style/head

bodydiv align=”center” 枫树林下/divdiv align=”center” p /p p /p p span
总共有/span?=$row1[0]; ?span 人/spanspan 来过/spanspan 这个网站/span/p
p span 总共有/span?=$row2[0]; ?span 人/spanspan 来过/spanspan
?=$user?网站 /span /p/div/body/html

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图