PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 15, 2017 10:36 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: hit counter and more
PostPosted: Mon Dec 04, 2017 4:07 pm 
Offline
Forum Contributor

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 491
Location: Victoria, BC
I have occasionally looked at ideas for my sites and other projects

Code:
CREATE TABLE `counter` ( `counter` INT( 20 ) NOT NULL );
INSERT INTO counter VALUES (0);


so now that I have a table in my database I was thinking, what can I do....

Syntax: [ Download ] [ Hide ]
 // Connects to your Database
 mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
 mysql_select_db("Database_Name") or die(mysql_error());
 


so with the database I was wondering if I could leverage it better?

Syntax: [ Download ] [ Hide ]
mysql_query("UPDATE counter SET counter = counter + 1");


seems obvious, then....

Syntax: [ Download ] [ Hide ]
$count = mysql_fetch_row(mysql_query("SELECT counter FROM counter"));


so then I guess....

Syntax: [ Download ] [ Hide ]
echo $count


so given the power of PHP and SQL, can I do better?

Google seems to be able to do more with their hit counter, can I expand on this crude design, how about a row for unique hits

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system, Joomla and Drupal are some alternatives


Top
 Profile  
 
 Post subject: Re: hit counter and more
PostPosted: Mon Dec 04, 2017 4:39 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6606
Location: WA, USA
What is the problem you are trying to solve?


Top
 Profile  
 
 Post subject: Re: hit counter and more
PostPosted: Mon Dec 04, 2017 6:00 pm 
Offline
Forum Contributor

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 491
Location: Victoria, BC
I was wondering, how hard would it be to track unique users for the day?

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system, Joomla and Drupal are some alternatives


Top
 Profile  
 
 Post subject: Re: hit counter and more
PostPosted: Mon Dec 04, 2017 7:51 pm 
Offline
Forum Newbie

Joined: Sun Nov 15, 2015 12:57 pm
Posts: 12
Aside from your question, the code you posted is obsolete and has been completely removed from Php. You need to use PDO https://phpdelusions.net/pdo.


Top
 Profile  
 
 Post subject: Re: hit counter and more
PostPosted: Tue Dec 05, 2017 12:16 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13459
Location: New York, NY, US
Vegan wrote:
I was wondering, how hard would it be to track unique users for the day?

There is software that does web server's log analysis and generates statistics like unique users. You can also use something like Google Analytics that does the same thing by adding Javascript to your website.

_________________
(#10850)


Top
 Profile  
 
 Post subject: Re: hit counter and more
PostPosted: Tue Dec 05, 2017 5:24 pm 
Offline
Forum Contributor

Joined: Fri Sep 05, 2008 3:34 pm
Posts: 491
Location: Victoria, BC
I use Google now, but I was looking to build countermeasures to click bots etc for an ad manager

_________________
Hardcore Games Legendary is the Only Way to Play!
Vegan Advocate 16 lbs grain to make only 1 lb meat, water for 6 months of showers and 34.1 lbs carbon dioxide
My sites are made with WordPress, which is a content management system, Joomla and Drupal are some alternatives


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Google [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group