I have a form that a person fills out to reserve a room for an event.
I have the event_start and event_end in the tabl event to designate start and end times ( both are in UNIX Time stamp)
Rooms are given an id #.
When a person fills out the form, I want the form to check the event table to see if the start time for the new event is in conflict with existing scheduled events for that particular room they want and return an error message indicating such. IF there is no event, then just insert the new event.
Right now Im just testing out some PHP code to see how it could work
I know of :
SELECT 1 FROM table_name WHERE time BETWEEN start AND end
for MySQL query, but I dont know if I've constructed the query correctly.
table_name = event
time (?) = dont know which this refers to
start (?) = is this the time that is given by the form for the new event
end (?) = same as start
So I just constructed below:
1053457200 = 5/20/2003 9:00 am
1053460800 = 5/20/2003 10:00 am
1053459000 = 5/20/2003 9:30 am
Which is basically what i have.
I have an event scheulded for that time already, and the query is suppose to check to see if the new event that starts at 1053459000 would conflict...
I have the event_start and event_end in the tabl event to designate start and end times ( both are in UNIX Time stamp)
Rooms are given an id #.
When a person fills out the form, I want the form to check the event table to see if the start time for the new event is in conflict with existing scheduled events for that particular room they want and return an error message indicating such. IF there is no event, then just insert the new event.
Right now Im just testing out some PHP code to see how it could work
I know of :
SELECT 1 FROM table_name WHERE time BETWEEN start AND end
for MySQL query, but I dont know if I've constructed the query correctly.
table_name = event
time (?) = dont know which this refers to
start (?) = is this the time that is given by the form for the new event
end (?) = same as start
So I just constructed below:
Code:
$db_name = "reserve";
$db_pw = "root";
$db_user = "root";
$db_server ="localhost";
$connection = mysql_connect($db_server,$db_user,$db_pw) or die("Couldn't connect to db.");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT 1 FROM event WHERE 1053459000 BETWEEN 1053457200 AND 1053460800 AND roomid=2";
$result = mysql_query($sql,$connection);
echo "$result";
1053457200 = 5/20/2003 9:00 am
1053460800 = 5/20/2003 10:00 am
1053459000 = 5/20/2003 9:30 am
Which is basically what i have.
I have an event scheulded for that time already, and the query is suppose to check to see if the new event that starts at 1053459000 would conflict...