0

/t5/dreamweaver-discussions/list-multiple-selection-to-mysql/td-p/713610
Jan 10, 2007
Jan 10, 2007
Copy link to clipboard
Copied
How do I take multiple selections from the List box in a form
in Dreamweaver 8 and post to MySQL?
I tried using implode as recommended here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=263&threadid=1112556&h...
This worked unless the user did not select any items in the list. Then I received a bad arguement error message.
I then tried just using POST without the implode and [] on the end of the select name, but this put the word "Array" in the column/row in the database instead of the data.
I then tried the POST with the [] on the select name and [] in the SQL statement: GetSQLValueString($_POST['appliances[]'], "text"), Dreamweaver would not let me associate this under Insert Record in the Server Behaviors section - so Null is put in the database.
I need to be able to post multiple items selected from a list box to MySQL, but allow the user not to select anything from the list box without receiving an error.
I tried using implode as recommended here: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=263&threadid=1112556&h...
This worked unless the user did not select any items in the list. Then I received a bad arguement error message.
I then tried just using POST without the implode and [] on the end of the select name, but this put the word "Array" in the column/row in the database instead of the data.
I then tried the POST with the [] on the select name and [] in the SQL statement: GetSQLValueString($_POST['appliances[]'], "text"), Dreamweaver would not let me associate this under Insert Record in the Server Behaviors section - so Null is put in the database.
I need to be able to post multiple items selected from a list box to MySQL, but allow the user not to select anything from the list box without receiving an error.
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer

Jan 11, 2007
Jan 11, 2007
Thank you so much for your assistance. Ultimately, it worked
with putting the [] after the name and with the following code:
GetSQLValueString(isset($_POST['appliances']) ? implode(" - ", $_POST['appliances']) : "", "text")
GetSQLValueString(isset($_POST['appliances']) ? implode(" - ", $_POST['appliances']) : "", "text")
LEGEND
,
/t5/dreamweaver-discussions/list-multiple-selection-to-mysql/m-p/713611#M105706
Jan 11, 2007
Jan 11, 2007
Copy link to clipboard
Copied
dulcey1 wrote:
> How do I take multiple selections from the List box in a form in Dreamweaver 8
> and post to MySQL?
Multiple select lists produce an array if anything is chosen, but do not
appear in the $_POST array if nothing is chosen. Since the name of your
multiple select list is appliances, you must put square brackets after
the name in the form (name="appliances[]").
To prevent errors, check whether $_POST['appliances'] exists. If it
does, extract the values with implode(). If it doesn't, create an value
to indicate that nothing was selected.
$appliances = (isset($_POST['appliances'])) ? implode(',',
$_POST['appliances']) : 'None';
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
> How do I take multiple selections from the List box in a form in Dreamweaver 8
> and post to MySQL?
Multiple select lists produce an array if anything is chosen, but do not
appear in the $_POST array if nothing is chosen. Since the name of your
multiple select list is appliances, you must put square brackets after
the name in the form (name="appliances[]").
To prevent errors, check whether $_POST['appliances'] exists. If it
does, extract the values with implode(). If it doesn't, create an value
to indicate that nothing was selected.
$appliances = (isset($_POST['appliances'])) ? implode(',',
$_POST['appliances']) : 'None';
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/dreamweaver-discussions/list-multiple-selection-to-mysql/m-p/713612#M105707
Jan 11, 2007
Jan 11, 2007
Copy link to clipboard
Copied
Thank you so much for your assistance. Ultimately, it worked
with putting the [] after the name and with the following code:
GetSQLValueString(isset($_POST['appliances']) ? implode(" - ", $_POST['appliances']) : "", "text")
GetSQLValueString(isset($_POST['appliances']) ? implode(" - ", $_POST['appliances']) : "", "text")
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

