Page 1 of 1

how to count page views

Posted: Mon Feb 09, 2009 2:33 am
by ecxzqute
hey guys.. can anyone please help me with this?.. i want to know the or count the number of views, visits, and currently visiting the pages on my site. how am i gonna do this?

Re: how to count page views

Posted: Mon Feb 09, 2009 5:07 am
by samsolomonraj
It is very simple... You can add one update query on that page.
Create one column in the database.

Then select that record on that page from db.. then increment the value by one and then update the value to the database..

Re: how to count page views

Posted: Tue Feb 10, 2009 5:33 am
by ecxzqute
i still don't get it.. can you plz give me a simple sample code?

Re: how to count page views

Posted: Tue Feb 10, 2009 5:38 am
by samsolomonraj
Ye man create one column in your database table like view_count.

Then

$sel1="select * from table_name where condition";
$qry1=mysql_query($sel1);
$res1=mysql_fetch_array($qry1);

$count=$res1['view_count'];

$sel2="update table_name set view_count=".$res1['view_count']."+1 where condition";
$res2 =mysql_query($sel2);


It will surely works..
Bye....

Re: how to count page views

Posted: Tue Feb 10, 2009 5:45 am
by ecxzqute
thanks man... i'll try this at home...