search
Homephp教程php手册超简单的php图片统计器

超简单的php图片统计器

Jun 13, 2016 am 10:11 AM
phptxtDodevicepicturedocumentNowuseofSimplestatisticsovertake

 超简单的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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version