成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

用PHP和MYSQL建立計數(shù)器過程詳解

瀏覽:43日期:2023-12-26 15:27:27

運行MYSQL.EXEmysql> 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文件內(nèi)容:

<html><body>

<?php$myvar = '來訪人數(shù):';echo $myvar;?>

<?phpmysql_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