| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Closed Join Date: May 2006
Posts: 57
![]() | Hit Counter Hosting. Hi all. Im currently in development of a website that will be hosting free Web Tools for webpages. I would like to create my own script for hosting Hit Counters but am i bit baffled by it. I can program in php and i can use SQL, but the question is, how would it work? Would i need to use SQL? I will want to bring up Stats aswell, so the user can check page stats. Could someone clear up my idea and try to explain how it all works please. So far i got the idea that a user will register, it will create a new Database entry then output a link to the Hit Counter. Everytime someone visits the users site it will log it and change the .gif image to update the hits. What im not getting is how does it all work. Is the user just hosting the .GIF file? So lets say his hit counter is called '1238_jon_webhit.gif' and the image is showing '2000' hits, when a new user hits his site, the .gif will automaticlly overwritter with '2001' hits? Please i need help on this |
| |
| | #2 (permalink) |
| Senior Member Join Date: May 2006 Location: Irvine, CA
Posts: 1,082
![]() ![]() ![]() ![]() | You can set up the MySQL so that there is a table called 'hits.' In hits, there are 2 fields: Name and Hits. (Of course, you can add fields if you wish, for ip, date, etc.) To update the MySQL, it is very simple. Somewhere on the page, add the following: Code: mysql_query("UPDATE hits SET hits=(hits+1) WHERE id = '$id'") or die (mysql_error()); |
| |
| | #3 (permalink) |
| Senior Member Join Date: Sep 2005 Location: Herts, UK
Posts: 3,796
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You would also probably need javascript, you dont want people to have to include a live php file from your server because it will cause them problems if your server is ever down.
__________________ RickM Web Design Forums - Over 22,000 Web Designers & Programmers just like you! WSDReg - Affordable Domain Registration. Serving NP members since 2006! |
| |