Time/Update database

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
Omnipotent
Forum Newbie
Posts: 3
Joined: Sun Dec 05, 2004 2:52 pm

Time/Update database

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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());
Omnipotent
Forum Newbie
Posts: 3
Joined: Sun Dec 05, 2004 2:52 pm

Post by Omnipotent »

But cron and task sheduler are stings that come with my server correect?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
Omnipotent
Forum Newbie
Posts: 3
Joined: Sun Dec 05, 2004 2:52 pm

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
Post Reply