View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Saving Multiple Selections

Thread began 11/25/2009 3:18 am by Jaffa | Last modified 11/24/2014 1:07 pm by Jaffa | 4589 views | 23 replies

elizabeth130596

Code for successful Insert Record using WA_DA & Multiple Options fr Select Field

In Header (actual options are xxx'd out)
----
<?php require_once('../Connections/mem1.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString"))
{
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname_rsRecordset = "-1";
if (isset($_GET['memberID'])) {
$colname_rsRecordset = (get_magic_quotes_gpc()) ? $_GET['memberID'] : addslashes($_GET['memberID']);
}
mysql_select_db($database_mem1, $mem1);
$query_rsRecordset = sprintf("SELECT * FROM tblPractice1 WHERE memberID = %s", GetSQLValueString($colname_rsPractice, "int"));
$rsRecordset = mysql_query($query_rsRecordset, $mem1) or die(mysql_error());
$row_rsRecordset = mysql_fetch_assoc($rsRecordset);
$totalRows_rsRecordset = mysql_num_rows($rsRecordset);
$colname_rsMembers = "-1";
if (isset($_GET['memberID'])) {
$colname_rsMembers = (get_magic_quotes_gpc()) ? $_GET['memberID'] : addslashes($_GET['memberID']);
}
mysql_select_db($database_mem1, $mem1);
$query_rsMembers = sprintf("SELECT memberID, name_last, name_first, email FROM tblMembers WHERE memberID = %s", GetSQLValueString($colname_rsMembers, "int"));
$rsMembers = mysql_query($query_rsMembers, $mem1) or die(mysql_error());
$row_rsMembers = mysql_fetch_assoc($rsMembers);
$totalRows_rsMembers = mysql_num_rows($rsMembers);?>
<?php
// WA Application Builder Insert
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
$WA_connection = $mem1;
$WA_table = "tblPractice1";
$WA_sessionName = "tblPractice1_practiceID";
$WA_redirectURL = "confirmation.php";
$WA_keepQueryString = false;
$WA_indexField = "practiceID";
$WA_fieldNamesStr = "memberID|DIMENS|INTERESTS|languages|ages_served|treatment_techniques|geo_location";
$WA_fieldValuesStr = "".((isset($_POST["memberID"]))?$_POST["memberID"]:"") ."" . "|" . "".((isset($_POST["DIMENS"]))?implode(", ", $_POST["DIMENS"]):"") ."" . "|" . "".((isset($_POST["INTERESTS"]))?implode(", ", $_POST["INTERESTS"]):"") ."" . "|" . "".((isset($_POST["languages"]))?implode(", ", $_POST["languages"]):"") ."" . "|" . "".((isset($_POST["ages_served"]))?implode(", ", $_POST["ages_served"]):"") ."" . "|" . "".((isset($_POST["treatment_techniques"]))?implode(", ", $_POST["treatment_techniques"]):"") ."" . "|" . "".((isset($_POST["treatment_techniques"]))?implode(", ", $_POST["treatment_techniques"]):"") ."";
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_mem1;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!-- end header -->
<!-- within body, within form -->
<form method="post" enctype="application/x-www-form-urlencoded" name="add_practice" id="add_practice">
<table>
<tr>
<td><p>Member ID: <?php echo $row_rsMembers['memberID']; ?><br />
&nbsp;
<input name="practiceID" type="hidden" id="practiceID" />
<input name="memberID" type="hidden" value="<?php echo $row_rsMembers['memberID']; ?>" size="32" />
</p>
<p><?php echo $row_rsMembers['name_last']; ?>, <?php echo $row_rsMembers['name_first']; ?></p></td>
</tr>
<tr>
<td>
<select name="DIMENS[]" size="5" multiple="multiple" id="DIMENS[]">
<option value="dimen1">dimen1</option>
<option value="dimen2">dimen2</option>
<option value="dimen3">dimen3</option>
</select>
</td>
</tr>
<tr>
<td>
<select name="INTERESTS[]" size="5" multiple="multiple" id="INTERESTS[]">
<option value="int1">int1</option>
<option value="int2">int2</option>
<option value="int3">int3</option>
</select></td>
</tr>
<tr>
<td>
<select name="languages[]" size="5" multiple="multiple" id="languages[]">
<option value="lang1">lang1</option>
<option value="lang2">lang2</option>
<option value="lang3">lang3</option>
</select>
</td>
</tr>
<tr>
<td><select name="ages_served[]" size="5" multiple="multiple" id="ages_served[]">
<option value="age1">age1</option>
<option value="age2">age2</option>
<option value="age3">age3</option>
</select></td>
</tr>
<tr>
<td><select name="treatment_techniques[]" size="5" multiple="multiple" id="treatment_techniques[]">
<option value="tech1" selected="selected">tech1</option>
<option value="tech2">tech2</option>
<option value="tech3">tech3</option>
</select></td>
</tr>
<tr>
<td><select name="geo_location[]" size="5" multiple="multiple" id="geo_location[]">
<option value="Loc1">Loc1</option>
<option value="Loc2">Loc2</option>
<option value="Loc3">Loc3</option>
</select></td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Submit" />
</td>
</tr>
</table>
</form>

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