I have one database table with all varchar and serveral columns; the most important being Monday_TimeStamp, Tuesday_TimeStamp...Friday_TimeStamp and StartTime(00:00:00....23:30:00) and EndTime(00:00:00....23:30:00).
I use a form to input some info to the database with something like this:
if ($submit && $StartTime <= $EndTime) {
if($Monday && !$monTimeStamp){
$sql = "UPDATE ScheduleRoom_New SET
Monday_TimeStamp='$TimeStamp',Monday_Room='$Room',Monday_Class='$Class',Monday_Section='$Section',
Monday_Teacher='$Teacher',Monday_Comments='$Comments' WHERE StartTime BETWEEN '$StartTime' AND '$EndTime'";
$result = mysql_query($sql);
echo "Monday added <font color>successfully</font> to the database with confirmation number
<font color>$TimeStamp</font>.<BR>";}//end Monday if
...and like this for every day of the week...
it is supposed to search in the database for existing TimeStamps according to the chosen days and times and either complain if field is not free or update if field is available.
idialy, the script is supposed to prevent any updating if any of the fields within range is not empty; however, if for example a user had previously updated monday from 00:00:00 to 03:00:00 and i by mistake (or not) decide to update monday from 00:00:00 to 04:00:00, i'm able to overwrite his/her previous record.
how to prevent this from happening? i have looked into arrays, loops, etc. but have not been able to find a plausible solution.
Any ideas???? thanks.