用PHP和MYSQL建立计数器过程详解_PHP教程
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文件内容:
$myvar = "来访人数:";
echo $myvar;
?>
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();
}
?>
推荐阅读
-
用PHP和MYSQL建立计数器过程详解
-
[原创] 多memcached 和 mysql 主从 环境下PHP开发: 代码详解_PHP教程
-
详解用phpmyadmin建立MYSQL数据库的过程_PHP教程
-
用PHP和MySQL构建一个数据库驱动的网站二_PHP教程
-
用 PHP 和 MySQL 保存和输出图片_PHP教程
-
php5与mysql5 web 开发技术详解-4 php控制结构和函数_PHP教程
-
PHP操作mysql函数详解,mysql和php交互函数_PHP教程
-
用PHP和MYSQL建立计数器过程详解_PHP教程
-
用 PHP 和 MySQL 保存和输出图片_PHP教程
-
用MySQL和PHP创建XML_PHP教程