mysql| Process | counter | detailed
Run 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)
The following writes the contents of the HTML file:
<body>
<?php
$myvar = "Number of visitors:";
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>