OK, here's the scoop. I'm learning PHP, I've got some pages which are .phpurl==http://=http:///url and I'm successfully accessing my database, blah blah blah. I can envision how to easily add a simple hit counter to any .phpurl==http://=http:///url pages, but I'd like to be able to have one on .htmlurl==http://=http:///url pages (no other reason for them to be .phpurl==http://=http:///url). Is there a way to do this? I don't care if the hits are a .gifurl==http://=http:///url or just text.
Check this out http//www.statlogger.com/
Thanks for the link, but I really want to write my own.
Yes you can add a counter to an HTML page, but it will require backend server site code (which can be PHP).
One approach is to embed a static img tag in your HTML code, with the src attribute pointing to a PHP page somewhere that counts the link and returns an image. So your image tag could look like
The hitcounter.php would simply increment the persistent count (database field) then stream the counter image back in the response. Or if you don't want to actually display a counter in the page, it could return nothing or just 1 pixel. Keep in mind that most hit-counters use algorithms to filter out bogus hits, such as page refreshes or multiple hits from the same IP within a given timeframe.
Ultimately code has to run on the server and the hit-count persisted somewhere, but yes that can be triggered from a static HTML page.