You can't hand edit any code within the code chunk written by the server behavior. You should instead add any loops or if statements outside of the code chunk to achieve your results and allow further edits through the UI. Here is an example of rewriting your code so that it has all of your custom code but can still be recognized by Dreamweaver:
<?php
$_POST['calendar_id'] = 1;
if ((((isset($_POST["Submit"]))?$_POST["Submit"]:"") != "")) {
foreach($_POST['room'] as $room) {
$Occurrence_End = ((isset($_POST["Recurring"]) && $_POST['Occurrence'] == 'end-by-end-date')?$_POST["ends_on"]:$_POST['EndAfter']);
?>
<?php
if ((((isset($_POST["Submit"]))?$_POST["Submit"]:"") != "")) {
$InsertQuery = new WA_MySQLi_Query($local_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "schedule";
$InsertQuery->bindColumn("schedule_name", "s", "".((isset($_POST["person_id"]))?$_POST["person_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("start_date", "s", "".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d')) ."", "WA_DEFAULT");
$InsertQuery->bindColumn("end_date", "s", "".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d')) ."", "WA_DEFAULT");
$InsertQuery->bindColumn("start_time", "s", "".((isset($_POST["start_time"]))?$_POST["start_time"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("end_time", "s", "".((isset($_POST["end_time"]))?$_POST["end_time"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("repeats", "s", "".((isset($_POST["Recurring"]))?$_POST["RecurType"]:"") ."", "WA_IGNORE");
$InsertQuery->bindColumn("repeat_every", "i", "".((isset($_POST["Recurring"]))?$_POST["Frequency"]:"") ."", "WA_IGNORE");
$InsertQuery->bindColumn("on_the", "i", "".((isset($_POST["Recurring"]))?$_POST["dow"]:"") ."", "WA_IGNORE");
$InsertQuery->bindColumn("repeat_on", "i", "".((isset($_POST["Recurring"]))?$_POST["RecurOn"]:"") ."", "WA_IGNORE");
$InsertQuery->bindColumn("occurrence", "s", "".((isset($_POST["Recurring"]))?$_POST["Occurrence"]:"") ."", "WA_IGNORE");
$InsertQuery->bindColumn("occurrence_end", "s", "".$Occurrence_End ."", "WA_IGNORE");
$InsertQuery->bindColumn("occurrence_storage", "s", "".$Occurrence_End ."", "WA_IGNORE");
$InsertQuery->bindColumn("type", "s", "".(isset($_GET['type']) ? $_GET['type'] : "person") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("room", "s", "".$room ."", "WA_DEFAULT");
$InsertQuery->bindColumn("position", "s", "".((isset($_POST["Position"]))?$_POST["Position"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("event", "i", "".$Parent_Event_List ."", "WA_DEFAULT");
$InsertQuery->bindColumn("schedule_attribute", "s", "".((isset($_POST["Category"]))?$_POST["Category"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("parent_event_id", "i", "".((isset($_GET["schedule"]))?$_GET["schedule"]:"") ."", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
<?php
}
if(count($_POST['room']) > 1)
{
$InsertGoTo = "". "event_schedule.php?day=".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d'))
."&schedule=".((isset($_GET["schedule"]))?$_GET["schedule"]:"1")
."&room="
."&event=".($Parent_Event_List)
."&calendar=".((isset($_GET["calendar"]))?$_GET["calendar"]:"0") ."";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
else
{
$InsertGoTo = "". "event_schedule.php?day=".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d'))
."&schedule=".((isset($_GET["schedule"]))?$_GET["schedule"]:"1")
."&room=".((isset($_POST["Room"][0]))?$_POST["Room"][0]:"")
."&event=".($Parent_Event_List)
."&calendar=".((isset($_GET["calendar"]))?$_GET["calendar"]:"0") ."";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
}
?>
Notice that all of the hand code was added either before or after the chunk of code controlled and written by the server behavior so that it can continue to be in charge of that area.