close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

IF / ELSE statements & foreach loops using the MySQLi plugin?

Thread began 5/19/2015 5:00 pm by Jason | Last modified 6/04/2015 6:01 pm by Jason | 1101 views | 8 replies

Ray BorduinWebAssist

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:
<?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.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...