cyrixware Posted February 18, 2008 Share Posted February 18, 2008 i created temporary scheduling for the students.. the problem is the time conflict. let say in the database the time start-end 8:00 10:00 exist! then after that wen i try to save 9:00 10:00 the message will display "choose another time." which is the time conflict. how to fix this prob? tnx i have here the source codes: <form name="form" method="post" action="addsubject.php"> <select name="startTime"> <option>08:00</option> <option>09:00</option> <option>10:00</option> <option>11:00</option> <option>12:00</option> </select> <select name="endTime"> <option>08:00</option> <option>09:00</option> <option>10:00</option> <option>11:00</option> <option>12:00</option> </select> <input type="submit" name="Submit" value="Submit"> <? $conn = mysql_connect("localhost","root","") or die(mysql_error()); $db = mysql_select_db("compare") or die(mysql_error()); if($_REQUEST['Submit'] == "Submit"){ $startTime = $_REQUEST['startTime']; $endTime = $_REQUEST['endTime']; //include("../connDB.php"); if(($endTime < $startTime) || ($endTime == $startTime)) { ?> <script language="JavaScript"> alert("Choose another time. Try Again."); win = window.open('addsubject.php','_self'); </script> <? }else{ $sql = "SELECT sum(*) FROM saveitem WHERE ($startTime < endTime) && (startTime < $endTime)"; $q_add = mysql_query($sql); $num = mysql_num_rows($q_add); if( $num != 0 ){ ?> <script language="JavaScript"> win = window.open('addsubject.php','_self'); alert("Time Conflict!"); </script> <? }else{ $sql = "INSERT INTO saveitem ( startTime, endTime) VALUES ('$startTime', '$endTime')"; if(!$q = mysql_query($sql)) { echo "<font color=#FF0000 size=2 face=Verdana, Arial, Helvetica, sans-serif> <center><b>Student ID Number/Username already exist!</b></center></font>"; } elseif(mysql_affected_rows() == 0) { echo "<font color=#FF0000 size=2 face=Verdana, Arial, Helvetica, sans-serif> <center><b>Cannot add record this time...</b></center></font>"; } else { ?> <script language="JavaScript"> alert("Student Record has been succesfully saved! "); win = window.open('addsubject.php','_self'); </script> <? } } } } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/91647-time-conflict/ Share on other sites More sharing options...
cyrixware Posted February 18, 2008 Author Share Posted February 18, 2008 i have 2 fields: startTime (type:time) endTime (type:time) Quote Link to comment https://forums.phpfreaks.com/topic/91647-time-conflict/#findComment-469362 Share on other sites More sharing options...
Daniel0 Posted February 18, 2008 Share Posted February 18, 2008 I don't get it. Do you seek a solution where you could have multiple identical start/end times? Quote Link to comment https://forums.phpfreaks.com/topic/91647-time-conflict/#findComment-469389 Share on other sites More sharing options...
cyrixware Posted February 18, 2008 Author Share Posted February 18, 2008 ex RM1 is occupied for the sched: 8:00 to 12:00 nn 12:00 to 3:00pm So wen i entered another sched let say.... 9:00 to 11:00am the it will not save in the dbase instead the message will be "Time Conflict. Choose another time. Quote Link to comment https://forums.phpfreaks.com/topic/91647-time-conflict/#findComment-469394 Share on other sites More sharing options...
cyrixware Posted February 19, 2008 Author Share Posted February 19, 2008 I fix now.. and here is the solution. hehehehe lol <form name="form" method="post" action="addsubject.php"> <select name="startTime"> <option>08:00</option> <option>08:30</option> <option>08:31</option> <option>09:00</option> <option>09:01</option> <option>09:30</option> <option>09:31</option> <option>10:00</option> <option>10:01</option> <option>10:30</option> <option>10:31</option> <option>11:00</option> <option>11:01</option> <option>11:30</option> <option>11:31</option> <option>12:00</option> <option>12:01</option> <option>12:30</option> <option>12:31</option> <option>13:00</option> <option>13:01</option> <option>13:30</option> <option>13:31</option> <option>14:00</option> <option>14:01</option> <option>14:30</option> <option>14:31</option> <option>15:00</option> <option>15:01</option> <option>15:30</option> <option>15:31</option> <option>16:00</option> <option>16:01</option> <option>16:30</option> <option>16:31</option> <option>17:00</option> <option>17:01</option> <option>17:30</option> <option>17:31</option> <option>18:00</option> <option>18:01</option> <option>18:30</option> <option>18:31</option> <option>19:00</option> <option>19:01</option> <option>19:30</option> <option>19:31</option> <option>20:00</option> <option>20:01</option> <option>20:30</option> </select> <select name="endTime"> <option>08:00</option> <option>08:30</option> <option>08:31</option> <option>09:00</option> <option>09:01</option> <option>09:30</option> <option>09:31</option> <option>10:00</option> <option>10:01</option> <option>10:30</option> <option>10:31</option> <option>11:00</option> <option>11:01</option> <option>11:30</option> <option>11:31</option> <option>12:00</option> <option>12:01</option> <option>12:30</option> <option>12:31</option> <option>13:00</option> <option>13:01</option> <option>13:30</option> <option>13:31</option> <option>14:00</option> <option>14:01</option> <option>14:30</option> <option>14:31</option> <option>15:00</option> <option>15:01</option> <option>15:30</option> <option>15:31</option> <option>16:00</option> <option>16:01</option> <option>16:30</option> <option>16:31</option> <option>17:00</option> <option>17:01</option> <option>17:30</option> <option>17:31</option> <option>18:00</option> <option>18:01</option> <option>18:30</option> <option>18:31</option> <option>19:00</option> <option>19:01</option> <option>19:30</option> <option>19:31</option> <option>20:00</option> <option>20:01</option> <option>20:30</option> </select> <input type="submit" name="Submit" value="Submit"> <? $conn = mysql_connect("localhost","root","") or die(mysql_error()); $db = mysql_select_db("compare") or die(mysql_error()); if($_REQUEST['Submit'] == "Submit"){ $startTime = $_REQUEST['startTime']; $endTime = $_REQUEST['endTime']; //include("../connDB.php"); if(($endTime < $startTime) || ($endTime == $startTime)) { ?> <script language="JavaScript"> alert("Choose another time. Try Again."); win = window.open('addsubject.php','_self'); </script> <? }else{ $sql = "SELECT * FROM saveitem WHERE '$startTime' BETWEEN startTime AND endTime || startTime = '$startTime'"; $q_add = mysql_query($sql); $num = mysql_num_rows($q_add); if( $num != 0 ){ ?> <script language="JavaScript"> win = window.open('addsubject.php','_self'); alert("Time Conflict!"); </script> <? }else{ $sql = "INSERT INTO saveitem ( startTime, endTime) VALUES ('$startTime', '$endTime')"; if(!$q = mysql_query($sql)) { echo "message"; } elseif(mysql_affected_rows() == 0) { echo "message"; } else { ?> <script language="JavaScript"> alert("Student Record has been succesfully saved! "); win = window.open('addsubject.php','_self'); </script> <? } } } } ?> </form> Quote Link to comment https://forums.phpfreaks.com/topic/91647-time-conflict/#findComment-470298 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.