Question:
How can I make a PHP hit counter that uses GET?
yabanize
2010-10-06 16:06:45 UTC
Hi

I want to make a Hit Counter that uses GET to keep track of names so index.php?name=john

For each name i want it to make a new hit counter for that name and display how many times the page has been browsed from that name
Four answers:
That Guy Over There
2010-10-06 20:51:19 UTC
Don't use GET, it isn't persistent in any way without a whole lot of unreliable twisting. Store the values in in the $_SESSION superglobal and just run session_start(); at the top of your script. It will initialize a session with the user. Then all you have to do is set indexes and values for the superglobal to save it for that particular user.



If you want to save it for a particular name for all visitors to see then you have to save it to a database table and track it there. Tell you what, I will simplify your life and just say check out CodeIgniter and start building your apps in it.
BeanCounter
2010-10-06 16:09:22 UTC
Yeah, you could connect to a MySQL server (for example) and store the hits in a database. I just can't imagine why you'd really want to do that other than as an academic exercise.
desmoke
2016-11-03 12:54:04 UTC
My purpose right right here is not to criticize, somewhat the different, however the respond given above would not thoroughly sparkling up the disaster, because of the reality It would not matter each and every view to each internet site in my view, It in basic terms counts the perspectives, the place they got here approximately would not remember. The question specifies something like this: -cyber web internet site a million replace into as quickly as seen 10 situations. -internet site 2 replace into as quickly as seen sixteen situations. -cyber web internet site 3 was once seen 40 situations. now not this: the completed internet site replace into seen one hundred situations. the simplest answer might desire to be to create N numbers of tables for N numbers of pages. Cheers.
anonymous
2010-10-07 09:52:59 UTC
How do you plan to store the information and in that; how do you plan to track the pages that you have?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...