时间:2021-07-01 10:21:17 帮助过:36人阅读
<?
//------[ 基本设定 ]-------
$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);
?>
<body> <? //------[基本设定]------- //准备好你的SQL语法 //印出该笔资料的所有栏位[阵列] //建立连接------通过(伺服器地址,使用者名称,使用者密码) //准备好你的SQL语法 //印出该笔资料的所有栏位的阵列 <body>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>3种计数器</title>
<style 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>
<p align="center" class="style1 style6">枫树林下
</p>
<p align="center">
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"><span class="style3">总共有</span><?=$row1[0]; ?><span class="style5">人</span><span class="style4">来过</span><span class="style2">这个网站
</span></p>
<p class="style1"><span class="style3">总共有</span><?=$row2[0]; ?><span class="style5">人</span><span class="style4">来过</span><span class="style2"><?=$user?>网站
</span>
</p>
</p>
</body>
</html>
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "512783";
$mysql_database = "jishuqi";
//-------
//建立连接------通过(伺服器地址,使用者名称,使用者密码)
$conn=mysql_connect( $mysql_server_name, $mysql_username, $mysql_password );
$sql = "SELECT COUNT(*) FROM `counter_1`WHERE user= '$user' AND TIME_TO_SEC(NOW()-`time`) < 3 AND ip='$REMOTE_ADDR'";
//进行查询(或者叫做执行,选取)
$result=mysql_db_query( $mysql_database, $sql,$conn );
//将查询后的结果-->抓出一笔
$row=mysql_fetch_row($result);
//print_r($row);
//清除查询结果
mysql_free_result($result);
if($row[0]==0)
{
//--基本设定
//准备好你的sql
$sql = "INSERT INTO `counter_1` ( `user` , `ip` , `time` ) VALUES ('$user', '$REMOTE_ADDR', 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 = "SELECT COUNT(*) FROM `counter_1` WHERE user='$user'";
//进行查询(或者叫做执行,选取)
$result=mysql_db_query( $mysql_database, $sql,$conn );
//将查询后的结果-->抓出一笔
$row=mysql_fetch_row($result);
//print_r($row);
//清除查询结果
mysql_free_result($result);
for ( $i=0; $i< strlen($row[0]);$i++)
{
$digit= substr($row[0],$i,1);
$pic.="<img src=\"timex/$digit.gif\" width=\"15\" height=\"20\">";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>3种计数器</title>
<style 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>
<p align="center" class="style1 style6">枫树林下
</p>
<p align="center">
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"><span class="style3">总共有</span><?=$row[0]; ?><span class="style5">人</span><span class="style4">来过</span><span class="style2">这个网站
</span></p>
<p class="style1"><span class="style3">总共有</span><?=$row[0]; ?><span class="style5">人</span><span class="style4">来过</span><span class="style2"><?=$user?>网站</span></p>
<p class="style1"><?=$pic?></p>
</p>
</body>
</html>