Establish a counter process with PHP and MySQL (WRRITEN BY NETYING 2001-6-1) ZrH # 163.Net http://www.filesee.com Run 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 Column 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)
The following is written in the HTML file content:
PHP $ MyVar = "Visitors:"; Echo $ MyVar;?>
php mysql_connect () or Die ("There is query"); $ query = "select * from tl"; $ results = mysql_db_query ("counter", $ query); if ($ results) { $ r = mysql_fetch_Array ($ results); $ 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>