Page 1 of 1

Dealing with Time

Posted: Fri Nov 07, 2003 12:16 pm
by mrvanjohnson
Can anyone point me to some tutorials on managing time with PHP/MySQL.

Specifically I am building a meeting room scheduling application for my office and I am having difficulty how to manage the time issue. Things like checking to make sure a room is open when scheduling it for a meeting. So if someone schedules a room from 12 to 1 then someone else attempts to schedule the room at 12:30, how do I have PHP check and see that time falls within the range of a time that the room is already in use?

It is a MySQL back end so would I be able to use SQL command to check this?

Any help would be greatly appreciated.

Posted: Fri Nov 07, 2003 12:44 pm
by Weirdan

Code: Select all

create table shedules (datetime start, datetime end,....);

Code: Select all

//adding shedule
 //$start contains requested start time, $end - end time
$res= mysql_query("select count(*) from shedules where $end between start and end or $start between start and end");
$qres=mysql_fetch_row();
if(!$qres){
 // room is open
} else {
  // already sheduled
}

Posted: Fri Nov 07, 2003 12:52 pm
by mrvanjohnson
Beautiful, thanks Weirdan I'll give that a try.