Hello friends in this artical i am going to teach you
how to make total visitors count system in website
using php and mysql. Here we use php and sql for visitors counts.
1st we need to connect database using sql.
<?php
//this is sql database connect
$conne= mysql_connect ("localhost", "root", "") or die("could not connect db here");
mysql_select_db("mydbname") or die(" sorry could not find database");
?>
What we do here ?
here we connect database using sql
$conne is a variable that store value of mysql_connect. we have local server so we write local host.
root is name and password is empty. our database name is mydbname.
now here we are use php for count.
<?php
//here for visitors count
$find_counts=mysql_query("SELECT * FROM our_user_count");
//here $find_counts is a variable that select db table from our_user_count.
//our_user_count is our database table
while($row=mysql_fetch_assoc($find_counts))
{
$our_counts= $row['counts'];
$new_v_count= $our_counts +1;
$update_count =mysql_query("UPDATE `mydbname`. `our_user_count` SET `counts` =$new_v_count ");
}
?>
here 1st we store value in variable and store in database now if you want po get data for database and
shows in website just write
<?php
echo $find_counts;
?>
This is a way you can create visitors counts in your website or blog.

No comments:
Post a Comment