Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

List Multiple Selection to MySQL

Guest
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.
TOPICS
Server side applications

Views

570
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
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")

Votes

Translate
LEGEND ,
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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 11, 2007 Jan 11, 2007

Copy link to clipboard

Copied

LATEST
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")

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines