PHP Developers Network
http://forums.devnetwork.net/

hit counter and more
http://forums.devnetwork.net/viewtopic.php?f=1&t=144868
Page 1 of 1

Author:  Vegan [ Mon Dec 04, 2017 4:07 pm ]
Post subject:  hit counter and more

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

Author:  requinix [ Mon Dec 04, 2017 4:39 pm ]
Post subject:  Re: hit counter and more

What is the problem you are trying to solve?

Author:  Vegan [ Mon Dec 04, 2017 6:00 pm ]
Post subject:  Re: hit counter and more

I was wondering, how hard would it be to track unique users for the day?

Author:  benanamen [ Mon Dec 04, 2017 7:51 pm ]
Post subject:  Re: hit counter and more

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.

Author:  Christopher [ Tue Dec 05, 2017 12:16 am ]
Post subject:  Re: hit counter and more

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.

Author:  Vegan [ Tue Dec 05, 2017 5:24 pm ]
Post subject:  Re: hit counter and more

I use Google now, but I was looking to build countermeasures to click bots etc for an ad manager

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/