手机
当前位置:查字典教程网 >编程开发 >php教程 >用PHP和MYSQL建立计数器过程详解
用PHP和MYSQL建立计数器过程详解
摘要:运行MYSQL.EXEmysql>createdatabasecounter;QueryOK,1rowaffected(0.10sec)my...

运行MYSQL.EXE

mysql> create database counter;

Query OK, 1 row affected (0.10 sec)

mysql> use counter;

Database changed

mysql> create table tl(id integer(2),count integer(5));

Query OK, 0 rows affected (0.21 sec)

mysql> show columns from tl;

+-------+--------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+--------+------+-----+---------+-------+

| id | int(2) | YES | | NULL | |

| count | int(5) | YES | | NULL | |

+-------+--------+------+-----+---------+-------+

2 rows in set (0.05 sec)

mysql> select * from tl;

Empty set (0.08 sec)

mysql> insert into tl(id,count) values(1,1);

Query OK, 1 row affected (0.02 sec)

mysql> select * from tl;

+------+-------+

| id | count |

+------+-------+

| 1 | 1 |

+------+-------+

1 row in set (0.03 sec)

下面编写HTML文件内容:

<html>

<body>

<?php

$myvar = "来访人数:";

echo $myvar;

?>

<?php

mysql_connect() or die("there are problems to connect to mysql!");

$query="select * from tl";

$result=mysql_db_query("counter",$query);

if($result){

$r=mysql_fetch_array($result);

$counter=$r["count"];

$counter=$counter+1;

echo $counter;

$query="update tl set count='$counter' where id=1";

$result=mysql_db_query("counter",$query);

mysql_close();

}

?>

</body>

</html>

【用PHP和MYSQL建立计数器过程详解】相关文章:

PHP 和 HTML

PHP输出缓冲控制Output Control系列函数详解

PHP的伪随机数与真随机数详解

PHP应用分页显示制作详细讲解

学习使用PHP数组

用PHP创建PDF中文文档

PHP生成器简单实例

配置最新的PHP加MYSQL服务器

常用PHP框架功能对比表

利用php和js实现页面数据刷新

精品推荐
分类导航