Counter/Accumulator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dunezone
Forum Newbie
Posts: 2
Joined: Tue Oct 31, 2006 12:02 am

Counter/Accumulator

Post by dunezone »

Ive been searching all night on how to make a counter, not a website counter but a way of having a number gradually add itself. For example the page displays 10, and every 5 seconds it will add 10 more. Can this be done with MySQL and PHP?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

As I understand the question you have the client download a page and then increment the counter.
Once the page is on the client machine you will need to use javascript or some such to implement a counter.
dunezone
Forum Newbie
Posts: 2
Joined: Tue Oct 31, 2006 12:02 am

Post by dunezone »

Well, the thing is the counter should always be counting up, even when the user does not have the page open. For example lets say its a small game where you are mining gold over time, and you make 100 gold per hour, then it should count up accordingly, Ive seen this done with some browser games, using PHP and I have no clue what else, maybe a database.
wyrmmage
Forum Commoner
Posts: 56
Joined: Sat Oct 28, 2006 12:43 pm
Location: boise, ID

Post by wyrmmage »

so, you're making a game?
Well, yes, the answer lies withing the topic of databases. What you really need to do is make a page that counts up (using javascript, perhaps) and then stores whatever number the counter got to( when the user leaves the page or goes elswhere) in a database field. When the user logs back in, you retrieve the value from that field and do whatever you want with it.
If you need help with programming a game, I have had some experience with that sort of thing :)

-wyrmmage
Post Reply