关于一个在线访问计数器的编程实例,有一些问题。
opendata.php
<?
if(!Mysql_connect("localhost","root","123"))
echo "连接数据库失败";
Elseif(!Mysql_select_db("mydata"))
echo "开启数据库失败";
?>
count.php
<?
include("opendata.php");
$time=Date("m").Date("d");
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
Setcookie("enter","True");
If(!Mysql_fetch_row($record))
{
$sql = "insert into counter(date,today,first,second,third,forth,fifth,sixth) values ('$time',0,0,0,0,0,0,0)";
Mysql_query($sql);
}
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
List($date,$today,$first,$second,$third,$forth,$fifth,$sixth)=Mysql_fetch_row($record);
$select=Floor(Date("G")/4)+1;
$sql="select * from total";
$record=Mysql_query($sql);
List($total)=Mysql_fetch_row($record);
If($enter<>"True")
{
$today++;
Switch($select)
{
case 1: $sql="update counter set today='$today',first=first+1 where date='$time'";
Mysql_query($sql);
break;
case 2: $sql="update counter set today='$today',second=second+1 where date='$time'";
Mysql_query($sql);
break;
case 3: $sql="update counter set today='$today',third=third+1 where date='$time'";
Mysql_query($sql);
break;
case 4: $sql="update counter set today='$today',forth=forth+1 where date='$time'";
Mysql_query($sql);
break;
case 5: $sql="update counter set today='$today',fifth=fifth+1 where date='$time'";
Mysql_query($sql);
break;
case 6: $sql="update counter set today='$today',sixth=sixth+1 where date='$time'";
Mysql_query($sql);
}
$total++;
$sql="update total set total=total+1";
Mysql_query($sql);
}
?>
<html>
<title>人数浏览统计</title>
<p align=center><img src=zct.jpg><br>
<?
$number = strlen($total);
For($i=0;$i<=$number-1;$i++)
$gif[$i] = substr($total,$i,1).".jpg";
echo "<font size=5>您是本站的第 </font>";
For($i=0;$i<=$number-1;$i++)
echo "<img src=".$gif[$i].">";
echo "<font size=5> 位上线的用户<br>";
$number = strlen($today);
For($i=0;$i<=$number-1;$i++)
$gif[$i] = substr($today,$i,1).".jpg";
echo "<font size=5>您是今天的第 </font>";
For($i=0;$i<=$number-1;$i++)
echo "<img src=".$gif[$i].">";
echo "<font size=5> 位上线的用户";
?>
<hr>
<center>
<form action=search.php method=post>
<table border=0>
<tr>
<td><font color=green>查询上线人数统计: </font></td>
<td><select size=1 name=month>
<option selected>01<option>02<option>03<option>04
<option>05<option>06<option>07<option>08<option>09
<option>10<option>11<option>12</select>月</td>
<td><select size=1 name=day>
<option selected>01<option>02<option>03<option>04
<option>05<option>06<option>07<option>08<option>09
<option>10<option>11<option>12<option>13<option>14
<option>15<option>16<option>17<option>18<option>19
<option>20<option>21<option>22<option<23><option>24
<option>25<option>26<option>27<option>28<option>29
<option>30<option>31</select>日</td><td>
<input type=submit name=SEND value=查询></td>
</tr>
<tr>
<td colspan=4 align=center>
<a href=search.php?month=<?echo Date("m")?>&day=<?echo Date("d")?>>
<font size=3>查看今日各时段流量统计</font></a></td>
</tr>
</table>
</form>
<font color=red size=5><?echo $errmsg;?></font>
</html>search.php
<?
include("opendata.php");
$time=$month.$day;
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
echo $record;
#If(!Mysql_fetch_row($record))
#{
#$errmsg="此日无上线的访客,请重新查询!";
#Header("Location:count.php?errmsg=$errmsg");
#}
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
List($date,$today,$first,$second,$third,$forth,$fifth,$sixth)=Mysql_fetch_row($record);
$p1=Sprintf("%.2f",$first/$today*100)."%";
$p2=Sprintf("%.2f",$second/$today*100)."%";
$p3=Sprintf("%.2f",$third/$today*100)."%";
$p4=Sprintf("%.2f",$forth/$today*100)."%";
$p5=Sprintf("%.2f",$fifth/$today*100)."%";
$p6=Sprintf("%.2f",$sixth/$today*100)."%";
?>
<html>
<title>各时段上线人数统计</title>
<body>
<p align=center><font color=blue size=5><?echo $month;?> 月
<?echo $day;?> 日上线记录统计表</font>
<hr>
<font color=green size=4>各时段上线次数统计图 </font>本日上线总数:
<?echo $today;?><br>
00-04时 <img src=bar.jpg width=<?echo $first;?> height=10> <?echo $first;?><br>
04-08时 <img src=bar.jpg width=<?echo $second;?> height=10> <?echo $second;?><br>
08-12时 <img src=bar.jpg width=<?echo $third;?> height=10> <?echo $third;?><br>
12-16时 <img src=bar.jpg width=<?echo $forth;?> height=10> <?echo $forth;?><br>
16-20时 <img src=bar.jpg width=<?echo $fifth;?> height=10> <?echo $fifth;?><br>
20-24时 <img src=bar.jpg width=<?echo $sixth;?> height=10> <?echo $sixth;?><br>
<hr>
<font color=green size=4>各时段上线比例统计图 </font>总比例: 100%<br>
00-04时 <img src=bar.jpg width=<?echo $first/$today*600;?> height=10>
<?echo $p1;?><br>
04-08时 <img src=bar.jpg width=<?echo $second/$today*600;?> height=10>
<?echo $p2;?><br>
08-12时 <img src=bar.jpg width=<?echo $third/$today*600;?> height=10>
<?echo $p3;?><br>
12-16时 <img src=bar.jpg width=<?echo $forth/$today*600;?> height=10>
<?echo $p4;?><br>
16-20时 <img src=bar.jpg width=<?echo $fifth/$today*600;?> height=10>
<?echo $p5;?><br>
20-24时 <img src=bar.jpg width=<?echo $sixth/$today*600;?> height=10>
<?echo $p6;?><br>
<hr>
<center><a href=count.php>回到首页</a>
</body>
</title>
</html>当我点击count.php上面的查询或者查看时,
Warning: Division by zero in D:\root\1\search.php on line 17Warning: Division by zero in D:\root\1\search.php on line 18Warning: Division by zero in D:\root\1\search.php on line 19Warning: Division by zero in D:\root\1\search.php on line 20Warning: Division by zero in D:\root\1\search.php on line 21Warning: Division by zero in D:\root\1\search.php on line 22月 日上线记录统计表
--------------------------------------------------------------------------------
各时段上线次数统计图 本日上线总数:
00-04时
04-08时
08-12时
12-16时
16-20时
20-24时 --------------------------------------------------------------------------------
各时段上线比例统计图 总比例: 100%
00-04时 Warning: Division by zero in D:\root\1\search.php on line 40
0 height=10> 0.00%
04-08时 Warning: Division by zero in D:\root\1\search.php on line 42
0 height=10> 0.00%
08-12时 Warning: Division by zero in D:\root\1\search.php on line 44
0 height=10> 0.00%
12-16时 Warning: Division by zero in D:\root\1\search.php on line 46
0 height=10> 0.00%
16-20时 Warning: Division by zero in D:\root\1\search.php on line 48
0 height=10> 0.00%
20-24时 Warning: Division by zero in D:\root\1\search.php on line 50
0 height=10> 0.00%--------------------------------------------------------------------------------回到首页
也就说说search.php上面的数据完全没有传过去,求解答,谢谢谢谢
opendata.php
<?
if(!Mysql_connect("localhost","root","123"))
echo "连接数据库失败";
Elseif(!Mysql_select_db("mydata"))
echo "开启数据库失败";
?>
count.php
<?
include("opendata.php");
$time=Date("m").Date("d");
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
Setcookie("enter","True");
If(!Mysql_fetch_row($record))
{
$sql = "insert into counter(date,today,first,second,third,forth,fifth,sixth) values ('$time',0,0,0,0,0,0,0)";
Mysql_query($sql);
}
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
List($date,$today,$first,$second,$third,$forth,$fifth,$sixth)=Mysql_fetch_row($record);
$select=Floor(Date("G")/4)+1;
$sql="select * from total";
$record=Mysql_query($sql);
List($total)=Mysql_fetch_row($record);
If($enter<>"True")
{
$today++;
Switch($select)
{
case 1: $sql="update counter set today='$today',first=first+1 where date='$time'";
Mysql_query($sql);
break;
case 2: $sql="update counter set today='$today',second=second+1 where date='$time'";
Mysql_query($sql);
break;
case 3: $sql="update counter set today='$today',third=third+1 where date='$time'";
Mysql_query($sql);
break;
case 4: $sql="update counter set today='$today',forth=forth+1 where date='$time'";
Mysql_query($sql);
break;
case 5: $sql="update counter set today='$today',fifth=fifth+1 where date='$time'";
Mysql_query($sql);
break;
case 6: $sql="update counter set today='$today',sixth=sixth+1 where date='$time'";
Mysql_query($sql);
}
$total++;
$sql="update total set total=total+1";
Mysql_query($sql);
}
?>
<html>
<title>人数浏览统计</title>
<p align=center><img src=zct.jpg><br>
<?
$number = strlen($total);
For($i=0;$i<=$number-1;$i++)
$gif[$i] = substr($total,$i,1).".jpg";
echo "<font size=5>您是本站的第 </font>";
For($i=0;$i<=$number-1;$i++)
echo "<img src=".$gif[$i].">";
echo "<font size=5> 位上线的用户<br>";
$number = strlen($today);
For($i=0;$i<=$number-1;$i++)
$gif[$i] = substr($today,$i,1).".jpg";
echo "<font size=5>您是今天的第 </font>";
For($i=0;$i<=$number-1;$i++)
echo "<img src=".$gif[$i].">";
echo "<font size=5> 位上线的用户";
?>
<hr>
<center>
<form action=search.php method=post>
<table border=0>
<tr>
<td><font color=green>查询上线人数统计: </font></td>
<td><select size=1 name=month>
<option selected>01<option>02<option>03<option>04
<option>05<option>06<option>07<option>08<option>09
<option>10<option>11<option>12</select>月</td>
<td><select size=1 name=day>
<option selected>01<option>02<option>03<option>04
<option>05<option>06<option>07<option>08<option>09
<option>10<option>11<option>12<option>13<option>14
<option>15<option>16<option>17<option>18<option>19
<option>20<option>21<option>22<option<23><option>24
<option>25<option>26<option>27<option>28<option>29
<option>30<option>31</select>日</td><td>
<input type=submit name=SEND value=查询></td>
</tr>
<tr>
<td colspan=4 align=center>
<a href=search.php?month=<?echo Date("m")?>&day=<?echo Date("d")?>>
<font size=3>查看今日各时段流量统计</font></a></td>
</tr>
</table>
</form>
<font color=red size=5><?echo $errmsg;?></font>
</html>search.php
<?
include("opendata.php");
$time=$month.$day;
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
echo $record;
#If(!Mysql_fetch_row($record))
#{
#$errmsg="此日无上线的访客,请重新查询!";
#Header("Location:count.php?errmsg=$errmsg");
#}
$sql="select * from counter where date='$time'";
$record=Mysql_query($sql);
List($date,$today,$first,$second,$third,$forth,$fifth,$sixth)=Mysql_fetch_row($record);
$p1=Sprintf("%.2f",$first/$today*100)."%";
$p2=Sprintf("%.2f",$second/$today*100)."%";
$p3=Sprintf("%.2f",$third/$today*100)."%";
$p4=Sprintf("%.2f",$forth/$today*100)."%";
$p5=Sprintf("%.2f",$fifth/$today*100)."%";
$p6=Sprintf("%.2f",$sixth/$today*100)."%";
?>
<html>
<title>各时段上线人数统计</title>
<body>
<p align=center><font color=blue size=5><?echo $month;?> 月
<?echo $day;?> 日上线记录统计表</font>
<hr>
<font color=green size=4>各时段上线次数统计图 </font>本日上线总数:
<?echo $today;?><br>
00-04时 <img src=bar.jpg width=<?echo $first;?> height=10> <?echo $first;?><br>
04-08时 <img src=bar.jpg width=<?echo $second;?> height=10> <?echo $second;?><br>
08-12时 <img src=bar.jpg width=<?echo $third;?> height=10> <?echo $third;?><br>
12-16时 <img src=bar.jpg width=<?echo $forth;?> height=10> <?echo $forth;?><br>
16-20时 <img src=bar.jpg width=<?echo $fifth;?> height=10> <?echo $fifth;?><br>
20-24时 <img src=bar.jpg width=<?echo $sixth;?> height=10> <?echo $sixth;?><br>
<hr>
<font color=green size=4>各时段上线比例统计图 </font>总比例: 100%<br>
00-04时 <img src=bar.jpg width=<?echo $first/$today*600;?> height=10>
<?echo $p1;?><br>
04-08时 <img src=bar.jpg width=<?echo $second/$today*600;?> height=10>
<?echo $p2;?><br>
08-12时 <img src=bar.jpg width=<?echo $third/$today*600;?> height=10>
<?echo $p3;?><br>
12-16时 <img src=bar.jpg width=<?echo $forth/$today*600;?> height=10>
<?echo $p4;?><br>
16-20时 <img src=bar.jpg width=<?echo $fifth/$today*600;?> height=10>
<?echo $p5;?><br>
20-24时 <img src=bar.jpg width=<?echo $sixth/$today*600;?> height=10>
<?echo $p6;?><br>
<hr>
<center><a href=count.php>回到首页</a>
</body>
</title>
</html>当我点击count.php上面的查询或者查看时,
Warning: Division by zero in D:\root\1\search.php on line 17Warning: Division by zero in D:\root\1\search.php on line 18Warning: Division by zero in D:\root\1\search.php on line 19Warning: Division by zero in D:\root\1\search.php on line 20Warning: Division by zero in D:\root\1\search.php on line 21Warning: Division by zero in D:\root\1\search.php on line 22月 日上线记录统计表
--------------------------------------------------------------------------------
各时段上线次数统计图 本日上线总数:
00-04时
04-08时
08-12时
12-16时
16-20时
20-24时 --------------------------------------------------------------------------------
各时段上线比例统计图 总比例: 100%
00-04时 Warning: Division by zero in D:\root\1\search.php on line 40
0 height=10> 0.00%
04-08时 Warning: Division by zero in D:\root\1\search.php on line 42
0 height=10> 0.00%
08-12时 Warning: Division by zero in D:\root\1\search.php on line 44
0 height=10> 0.00%
12-16时 Warning: Division by zero in D:\root\1\search.php on line 46
0 height=10> 0.00%
16-20时 Warning: Division by zero in D:\root\1\search.php on line 48
0 height=10> 0.00%
20-24时 Warning: Division by zero in D:\root\1\search.php on line 50
0 height=10> 0.00%--------------------------------------------------------------------------------回到首页
也就说说search.php上面的数据完全没有传过去,求解答,谢谢谢谢
解决方案 »
- 不显示删除回复显示所有回复显示星级回复显示得分回复 怎样设定iis执行时间 我上传文件到网站,五分钟就断了
- 正则表达式排除不管用啊,各位看看我这个写的有什么错误
- 一段简单正则,请帮忙
- 求教PHP+MYSQL的文件上传下载代码要怎样写?
- 谁能给我一个输入密码进入论坛的例子
- 如何在插入数据的同时知道其id号
- OCI如何返回select得到的记录数?
- $_SESSION['expanded'][$_GET['expand']] = true;什么意思
- 我现在网站系统是dedecms,我想用Thinkphp框架开发一些自己想要的功能,但是怎么整合到一起呢,还有就是后台功能也要用tp来写?
- 后台管理
- php如何规范代码书写?
- html td中用鼠标选择不了内容
看里面有没值, 没值
<?php
if(!mysql_connect("localhost","root","123"))
echo "连接数据库失败"; if(!mysql_select_db("mydata"))
echo "开启数据库失败";
?>