PHP counter for visiter….
First we create a table in mysql database.
Table name counter. And its contain 2 column for showing the no. of visitor on php page.
Table coading in mysql…
CREATE TABLE `counter` (
`id` INT( 10 ) NOT NULL ,
`cntr` INT( 100 ) NOT NULL
) ENGINE = MYISAM ;
Now insert the first value…
INSERT INTO `counter` ( `id` , `cntr` )
VALUES (
'1', '1'
);
Here we take a field id and counter.
Coading at visiter page….
< ?php
include("connect/conn.php");
mysql_query("update counter set cntr = cntr +1 where id ='1';");
?>
This will update the value of counter by one after refresh the page.
Show the no of visitor on page….
< ?php
$q = mysql_query("select * from counter where id ='1' ");
$row = mysql_fetch_array($q);
echo $row['cntr'];
?>
This code show the total no. of visitor on page.