Help! Time function to add "30000" to datatable

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

Locked
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Help! Time function to add "30000" to datatable

Post by Goofan »

Hi
I need a counter that after it hits its mark (1 hour)
it will uppdate the datatable (money) and add 30000 to all of theire values...

it will count even if noone is online...
so that whenever it reaches over 1 hour it will add. or that it will count all the missing "hours" and add them.

Meaning:
I got a "game" where someone can log in

ive been looking for a code an all ive found is like this with time (nothing out of the ordinary)

http://php.net/manual/en/function.time.php
Last edited by Goofan on Mon Nov 30, 2009 6:10 am, edited 1 time in total.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: time function to add "30000" to datatable

Post by daedalus__ »

hi

i think you are misunderstanding the capabilities of php.

try cron:

http://en.wikipedia.org/wiki/Cron

or use another language. i like c# for situations such as the one you described
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: time function to add "30000" to datatable

Post by Goofan »

ok i think i can manage it by using cron feutures... thanks alot (other ide´s are allways welcomed).
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: time function to add "30000" to datatable

Post by daedalus__ »

(cron isn't an ide) :roll:
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: time function to add "30000" to datatable

Post by Goofan »

i know :D

didnt actually know what to call it except idé or algorithm :wink:


-Thanks
-Thomas
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: time function to add "30000" to datatable

Post by Goofan »

ok so how to manage the "cron" into working code...? i understand the cron but not how to get it into code-form.
My try:

Code: Select all

 
"fetching"
$pengar = $row['pengar']
-------------------------
if time = 0 * * * * then run //should be set to run ever 30 min has passed
{
uppdate konto SET $pengar=$pengar + 30000
} 
 
not a working code but this is my "working process" and as u know im working with alot of diffrent code-strippes at the same time.
can u please show me a workable code string so that i can modifie it after my needs and ...such
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Help! Time function to add "30000" to datatable

Post by daedalus__ »

cron is a daemon that runs on the operating system. it is not a part of php.

i have never used cron before. but you have to set up cron to run the php script at the specified interval.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Help! Time function to add "30000" to datatable

Post by Goofan »

but isnt there a easier way to do this "with php".

Im thinking of getting a date desplayer:
so that it will show for exampel:
12:30

then i can say something like if $time = 12:30 then "uppdate database pengar and add +30000 to the datacells"
then i can say it again like if $time = 13:30 then....
and so on.


Now my "new" question would be like if there is a function so that u can see current time (sorry got this above more or less).
need a more uppgraded where i can see some basic code´s to work with just not "the algorithm".

if i got this on a server this would run every hour... make a diffrent in the database every hour.

-Thanks in advance
-Thomas
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Help! Time function to add "30000" to datatable

Post by Goofan »

ok i found this...


$today = date("H:i:s");
on page:
http://php.net/manual/en/function.date.php
I think i can modify it to make as i want it to :D



-Thanks
-Thomas
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Help! Time function to add "30000" to datatable

Post by John Cartwright »

Locked.
Locked