Page 1 of 1

hit counter and more

Posted: Mon Dec 04, 2017 3:07 pm
by Vegan
I have occasionally looked at ideas for my sites and other projects

Code: Select all

 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....

Code: Select all

 // 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?

Code: Select all

mysql_query("UPDATE counter SET counter = counter + 1");
seems obvious, then....

Code: Select all

$count = mysql_fetch_row(mysql_query("SELECT counter FROM counter"));
so then I guess....

Code: Select all

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

Re: hit counter and more

Posted: Mon Dec 04, 2017 3:39 pm
by requinix
What is the problem you are trying to solve?

Re: hit counter and more

Posted: Mon Dec 04, 2017 5:00 pm
by Vegan
I was wondering, how hard would it be to track unique users for the day?

Re: hit counter and more

Posted: Mon Dec 04, 2017 6:51 pm
by benanamen
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.

Re: hit counter and more

Posted: Mon Dec 04, 2017 11:16 pm
by Christopher
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.

Re: hit counter and more

Posted: Tue Dec 05, 2017 4:24 pm
by Vegan
I use Google now, but I was looking to build countermeasures to click bots etc for an ad manager