Hello, I am trying to complete a project and my client has requested the following thing be created: A counter that starts at a specific number "X" The number goes up by a specific number each second "Y" When someone visits a site, the browser gets the number to start from on the server "X" and then they can visually see the number going up each second by "Y" When they close the browser, the number is still being counted up (this is being done server side) When they come back to the site, they see the correct number regarding the amount of time that has passed (if they come back 2 days later, they will see the number increased by 2 days of time) I know that this has to be done server side and the browser has to reference the number generated by the script on the server, but I need to know: 1. If this is possible 2. The general idea of how this is done? My design team is telling me that this is not possible to do but I'm almost certain it is, being that there are sites like this: http://www.usdebtclock.org/ on the web. Any insight by a knowledgeable person in this regard will be greatly appreciated. Thank you.
Your main problem is identifying the visitor on their return. If they are logged into the site you just have to save the time they were allocated their "X" and then on each return you output the updated value of "X". Javascript handles the visual "count up" but PHP generates the start value. If they aren't logged in you have bigger problems as you have to somehow identify Probably the best way would be to store a cookie with the date they are allocated "X" and then reference that cookie on subsequent visits. Sounds more like homework than a client project though
Ah the X and Y's do make it sound like a homework assignment, haha. Every user needs to see the same number at the same time, that information may be helpful. With this being the case, is it still needed to keep track of who visited the site using cookies? (there will be no login)
It is not real time value for everyone at the same time on the site you said. I checked it with two different browsers and they are not the same values. That said, the increased value of counters are on each client browser. I guess what we could do here is when the browser exits, we may store the greater value on database. Could it be what you mean?
Sorry if this was misleading... In short .. what would the process be to have a counter... that is always counting up from the time it is initiated. This would need to be something that would pull from a script that is run on the server. Therefore it is always running and thus when any user visits the site, they will never see the same number, it will always be higher than before etc etc.. From what I have gathered so far, this is something that would need to be executed with some cron jobs on the server. What I am trying to find out is if there is anything already out here on this vast world we call the internet, that would serve as a guide to implement this? Thanks!
Josiah: include 'really_easy_functions.php' PHP: Seriously though does the number start again for each new user or is it for the entire site? This isn;t the kind of thing you would use cron for, all you need to save is one little static number and then run javascript based off of that.
It is the same number for the entire site. The number does not start again for each new user. *Edit: The issue I was having is when they first created the counter, it would only count up while the user had the browser open, and would start at the same base number each time someone went to the site for the first time (this being because the counter was created 100% client side). What the client needs is one number that is always going up and for users to be able to see what the number is currently at, as well as see it counting up in real time on their browsers. The same number for every user. Thank you for all of the replys and help so far, and for all future help and replys.
You server side script. Something like this http://www.hscripts.com/scripts/php/uniqueCounter.php. I was create counter script for my client, PM me if you need help with server side.