Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

view counter php mysql?

make money online
ivan Offline referral

Posts: 717
Joined: Jul 2013
Reputation: 6

Senior Member
How can I count web page views using PHP that will store that data in my database SQL?
surenot Offline referral

Posts: 498
Joined: Jan 2014
Reputation: 16

Senior Member
It's pretty easy @ivan Wink

1. Lets create a table in your database where all views will be stored and then polled from.

CREATE TABLE `counter` ( `counter` INT( 20 ) NOT NULL );

2. Now lets create PHP code that will update that table each time someone views the page, and also the same code will retrieve the views value!

PHP Code:
// Connect Database 
mysql_connect("hostname""username""password") or die(mysql_error()); 
mysql_select_db("database_name") or die(mysql_error()); 

//Update Table
mysql_query("UPDATE counter SET counter = counter + 1");

//Retrieves count 
$views mysql_fetch_row(mysql_query("SELECT counter FROM counter"));

//Shows count
print "$views[0]"
Rapidsoft technologies Offline referral

Posts: 224
Joined: Sep 2015
Reputation: 1

It can be done some other ways like just create table and follow the above procedure.

Google this topic

User(s) browsing this thread: 1 Guest(s)