how to count page views
Moderator: General Moderators
how to count page views
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?
-
samsolomonraj
- Forum Newbie
- Posts: 12
- Joined: Mon Feb 09, 2009 3:34 am
- Location: India, Chennai
Re: how to count page views
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..
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
i still don't get it.. can you plz give me a simple sample code?
-
samsolomonraj
- Forum Newbie
- Posts: 12
- Joined: Mon Feb 09, 2009 3:34 am
- Location: India, Chennai
Re: how to count page views
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....
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....
Last edited by samsolomonraj on Wed Mar 18, 2009 7:27 am, edited 1 time in total.
Re: how to count page views
thanks man... i'll try this at home...