超简单的php图片统计器_PHP教程
CREATE TABLE `count` (
`id` int(10) NOT NULL auto_increment,
`value` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=98 ;
好数据准备好了下面我们来看看程序是怎么实现的吧.
//浏览页面时加入一条记录,从而达到访问加1.
$conn=mysql_connect("localhost","root","root");
//echo mysql_error();
mysql_query("set names gb2312");
mysql_select_db("guest");
$sql="INSERT INTO `count` ( `id` , `value` ) VALUES ('', '32')";
$result=mysql_query($sql);
if ($result) {
echo "插入成功.";
}
mysql_close($conn);
//读出记录数据count(*)
$conn=mysql_connect("localhost","root","root");
//echo mysql_error();
mysql_query("set names gb2312");
mysql_select_db("guest");
$mysql="select * from `count`";
$result=mysql_query($mysql);
$row=mysql_num_rows($result);
for($i=0;$i
$a=substr($row,$i,1);
$str.= "";
}
?>
嗯,php代码写得有一点乱喽,但工能还是能实现的吧.