IF / ELSE statements & foreach loops using the MySQLi plugin?
I was wondering if there is a way to do some of the functions using the plugin. I've hand written them into my code for now, and they are working, but I'd like to still be able to use my plugin. Currently it doesn't recognize the queries I've made changes to (understandably). This is the code I have working now.
<?php
$_POST['calendar_id'] = 1;
if ((((isset($_POST["Submit"]))?$_POST["Submit"]:"") != "")) {
foreach($_POST['Room'] as $room)
{
$InsertQuery = new WA_MySQLi_Query($local_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "calendarevents";
$InsertQuery->bindColumn("calendar_events_name", "s", ((isset($_POST["insert_id"]))?$_POST["insert_id"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_start_date", "s", ((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d')), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_end_date", "s", ((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d')), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_start_time", "s", ((isset($_POST["start_time"]))?$_POST["start_time"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_end_time", "s", ((isset($_POST["end_time"]))?$_POST["end_time"]:""), "WA_DEFAULT");
if(isset($_POST['Recurring']))
{
$InsertQuery->bindColumn("calendar_events_repeats", "s", ((isset($_POST["RecurType"]))?$_POST["RecurType"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_repeat_every", "i", ((isset($_POST["Frequency"]))?$_POST["Frequency"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_on_the", "i", ((isset($_POST["dow"]))?$_POST["dow"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_repeat_on", "i", ((isset($_POST["RecurOn"]))?$_POST["RecurOn"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_occurrence", "s", ((isset($_POST["Occurrence"]))?$_POST["Occurrence"]:""), "WA_DEFAULT");
$Occurrence_End = ((isset($_POST["Occurrence"]) && $_POST['Occurrence'] == 'end-by-end-date')?$_POST["ends_on"]:$_POST['EndAfter']);
$InsertQuery->bindColumn("calendar_events_occurrence_end", "s", $Occurrence_End, "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_occurrence_storage", "s", $Occurrence_End, "WA_DEFAULT");
}
$InsertQuery->bindColumn("calendar_events_type", "s", (isset($_GET['type']) ? $_GET['type'] : "person"), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_attribute", "s", $room, "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_attribute_2", "s", ((isset($_POST["Position"]))?$_POST["Position"]:""), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_event_list", "i", $Parent_Event_List, "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_calendar_id", "i", ((isset($_POST["calendar_id"]))?$_POST["calendar_id"]:"1"), "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_attribute_3", "s", "".((isset($_POST["Category"]))?$_POST["Category"]:"") ."", "WA_DEFAULT");
$InsertQuery->bindColumn("calendar_events_shift_event_parent_id", "i", "".((isset($_GET["calendar_events_id"]))?$_GET["calendar_events_id"]:"") ."", "WA_DEFAULT");
$InsertQuery->execute();
}
if(count($_POST['Room']) > 1)
{
$InsertGoTo = "event_schedule.php?day=".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d'))
."&calendar_events_id=".((isset($_GET["calendar_events_id"]))?$_GET["calendar_events_id"]:"1")
."&calendar_events_event_list=".($Parent_Event_List);
}
else
{
$InsertGoTo = "event_schedule.php?day=".((isset($_POST["start_date"]))?$_POST["start_date"]:date('Y-m-d'))
."&calendar_events_attribute=".((isset($_POST["Room"][0]))?$_POST["Room"][0]:"")
."&calendar_events_id=".((isset($_GET["calendar_events_id"]))?$_GET["calendar_events_id"]:"1")
."&calendar_events_event_list=".($Parent_Event_List);
}
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>
How can I make this work with the MySQLi plugin?
Is there a way to write loops and IF statements in the plugin?