Page 1 of 1

Time/Update database

Posted: Sun Dec 05, 2004 3:00 pm
by Omnipotent
Ive been working on this code for every 30 minutes it adds, lets say 100 points, to a persons total. I dont even know where to get started. Do I try something like:

if ( $time == 00:00,00:30,01:00...and so on)
{
$result = UPDATE BoC SET points=points+$points WHERE username=$username
$gamer = mysql_query($result) or die("Query failed : " . mysql_error());
}
$points = points+100

Except Id actually look at some code instead of typing this just off of my head. So is that even close or am I way off?

Posted: Sun Dec 05, 2004 4:42 pm
by timvw
Just choose cron (-NIX) or task sheduler (-WIN) to make sure the task get's executed at the times you want...

set desired points: $points = 100;
initialise query: $query = "UPDATE foo SET points = points + $points";
perform query: $result = mysql_query($query) or die(mysql_error());

Posted: Sun Dec 05, 2004 6:31 pm
by Omnipotent
But cron and task sheduler are stings that come with my server correect?

Posted: Sun Dec 05, 2004 6:35 pm
by kettle_drum
Yes. as timvw says - if its an unix server it will be cron, and if its a windows server it will be task scheduler. Find out what OS your server is running and then either google for info on task scheduler or do a 'man cron' on the unix shell.

Posted: Mon Dec 06, 2004 3:07 pm
by Omnipotent
So if I want to prevent someone from taking a quiz quetion more then once a day I assume thats in the cron/task schedular too?

Posted: Mon Dec 06, 2004 4:36 pm
by timvw
Just register all the times when someone takes a quiz.

Before someone tries to take a quiz, see when he last took a quiz, and then decide if he is allowed to take already another one.