The INSERT extension that comes with DW8 fails to insert anything but
the last selection in a multiple select text field. This is because
the data have to be treated as an array. But because of the way the
INSERT code is written, I'm having a hard time figuring out how to get
more than one selection inserted. Before I give up and hand-code this
form (would *really* rather not!), I'd appreciate any suggestions for
making the below work (the multiple select data is inserted into the
last field, "grade"):
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO classroom (orgName, url, inClass,
webResource, classMatls, lessonPlans, careers, keywords, topic, grade)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['orgName'], "text"),
GetSQLValueString($_POST['url'], "text"),
GetSQLValueString(isset($_POST['inClass']) ?
"true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['webResource']) ?
"true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['classMatls']) ?
"true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['lessonPlans']) ?
"true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['careers']) ?
"true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['keywords'], "text"),
GetSQLValueString($_POST['topic'], "text"),
GetSQLValueString($_POST['grade'], "text"));
Here's the form field code (array brackets in the field name are
required, but the above MySQL code for this field obviously isn't
right yet):
<td><select multiple="multiple" name="grade[]" size="13" />
<option value="K ">K</option>
<option value="01 ">1</option>
<option value="02 ">2</option>
<option value="03 ">3</option>
<option value="04 ">4</option>
...etc.
</select></td>
One person suggested modifying the GetSQLValueString to this:
GetSQLValueString($_POST['grade'][0], "text"));
But still no luck.
Marcus Duke
Web Editor
Washington Sea Grant
mduke@u.washington.edu
206-685-0171
--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Dreamweaver/Browse/
Manage your subscription: http://www.ListSearch.com/Dreamweaver/