Page 1 of 1
Help! Time function to add "30000" to datatable
Posted: Fri Nov 27, 2009 2:02 pm
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
Re: time function to add "30000" to datatable
Posted: Fri Nov 27, 2009 2:13 pm
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
Re: time function to add "30000" to datatable
Posted: Fri Nov 27, 2009 4:49 pm
by Goofan
ok i think i can manage it by using cron feutures... thanks alot (other ide´s are allways welcomed).
Re: time function to add "30000" to datatable
Posted: Fri Nov 27, 2009 5:05 pm
by daedalus__
(cron isn't an ide)

Re: time function to add "30000" to datatable
Posted: Fri Nov 27, 2009 5:11 pm
by Goofan
i know
didnt actually know what to call it except idé or algorithm
-Thanks
-Thomas
Re: time function to add "30000" to datatable
Posted: Mon Nov 30, 2009 5:01 am
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
Re: Help! Time function to add "30000" to datatable
Posted: Mon Nov 30, 2009 4:05 pm
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.
Re: Help! Time function to add "30000" to datatable
Posted: Tue Dec 01, 2009 1:58 am
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
Re: Help! Time function to add "30000" to datatable
Posted: Tue Dec 01, 2009 7:26 am
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
-Thanks
-Thomas
Re: Help! Time function to add "30000" to datatable
Posted: Tue Dec 01, 2009 3:25 pm
by John Cartwright
Locked.