Home >php教程 >php手册 >超简单的php图片统计器

超简单的php图片统计器

WBOY
WBOYOriginal
2016-06-13 10:11:29823browse

 超简单的php图片统计器,这种统计器以前我是用txt文件做的,现在就直接用数据库实现吧.先来看看数据结构吧.

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图片统计器";
   }
?>

页面总共有个人浏览

嗯,php代码写得有一点乱喽,但工能还是能实现的吧.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php注入祥解Next article:网页病毒清除办法