dsp77 Posted October 21, 2009 Share Posted October 21, 2009 i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same date, time and room without receiving any error i don't know where to start to compare the days hours with location (the 2 different tables are confusing me). To explain better i have like this: Table1 with: Start Date, End Date, Start Hour, End Hour and other things not important for validation Table2 with: Room1, Room2, Room3 etc What MYSQL syntax to use or what code i'm brain dead now i don't know from where to start, at least someone can tell me the logic from where to start. Quote Link to comment Share on other sites More sharing options...
farkewie Posted October 21, 2009 Share Posted October 21, 2009 Hi, Below is untested but should give some basic logic. just want to see if there is an appointment with a start time between your new appointments start and end time. <?php $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; $dbname = 'database'; mysql_connect($dbhost, $dbuser, $dbpass) or die("Error connecting to mysql"); mysql_select_db($dbname); $startDate = ""; $startTime = ""; $endDate = ""; $endTime = ""; $room = ""; $query = "SELECT * FROM Table1 WHERE table='".table."' AND startDate='".$startDate."' AND startTime BETWEEN '".$startTime."' AND '".$endTime."'"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0){ //an appointment already in that timeframe. } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.