|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
学习PHP第3天,自己写的计数器.
<?php
/*create table hunter.hunter3(
ip VARCHAR(15),
day date,
time time,
counter int not null
)
*/
$conn=mysql_connect(\"127.0.0.1\",\"hunter\",\"\");
$ip=$_SERVER[\"REMOTE_ADDR\"];
$day=date(\"Ymd\");
$time=date(\"H:i:s\");
$SQL=\"SELECT COUNT(*) AS TCOUNT FROM hunter.hunter3\";
$result=mysql_query($SQL);
$obj=mysql_fetch_object($result);
$sum=$obj->TCOUNT;
$sql=\"select * from hunter.hunter3 where ip=\'$ip\' and day=\'$day\'\";
$result=mysql_query($sql,$conn);
if($row=mysql_fetch_row($result))
{
echo\"你是第\".$sum.\"位访问者\";
}
else
{
++$sum;
$sql=\"insert into hunter.hunter3 VALUES(\'$ip\',\'$day\',\'$time\',\'$sum\')\";
mysql_query($sql,$conn);
echo\"鱼,你是第\".$sum.\"位访问者\";
}
mysql_close($conn);
?> |
|
|
|
|
|
|