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

Inserting Multiple Select Into Database

Explorer ,
Jul 21, 2008 Jul 21, 2008
I've never had to deal with this before and now have a client that wants to have a multiple select field inserted into a database along with a mirad of other fileds. How is this typically dealt with? I have set the multiple option to work, but only one of the selected fields are inserted.

Thanks
TOPICS
Server side applications
537
Translate
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
Explorer ,
Jul 23, 2008 Jul 23, 2008
Does no one understand this question? Did I not make myself clear?

Just wondering as I am sure this is something that is done often. Let me give an example. I need to collect info in reagrds to the person's contact info, first name, last naem, email, etc. Then I need something like professional experience (choose all that apply): Computers, Banking, Human Resourses, etc. etc.

Everything is inserted except only one if the mulitple select fileds is inserted.

Any ideas?

Translate
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
LEGEND ,
Jul 23, 2008 Jul 23, 2008
On Wed, 23 Jul 2008 13:53:16 +0000 (UTC), "VernMan"
<webforumsuser@macromedia.com> wrote:

>Does no one understand this question? Did I not make myself clear?

It's done differently depending on what scripting language you're
using. Since you didn't specify, it's not really possible to answer.

Gary
Translate
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
Explorer ,
Jul 24, 2008 Jul 24, 2008
Well I am using php and MySQL, sorry I negelected to mention that. 🙂
Translate
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
LEGEND ,
Jul 24, 2008 Jul 24, 2008
On Thu, 24 Jul 2008 11:48:14 +0000 (UTC), "VernMan"
<webforumsuser@macromedia.com> wrote:

>Well I am using php, sorry I negelected to mention that. :)

In that case, you need to name the select so that PHP will treat it as
an array. You do that by naming it with square brackets on the end of
the name:

<select multiple="multiple" name="whatever[]">

Then, in your PHP code that processes the form, join the array
elements. For example, this will give you a comma separated list:

$whatever=join(', ',$_POST['whatever']);

Insert $whatever into your database.

Gary
Translate
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
Explorer ,
Aug 21, 2008 Aug 21, 2008
Thank for your response that worked great.

Now that I have the data inserted into the datbase I need to have a way to have each of those items selected on an update form whem multiple items are submited.

To be clear, now I have a field in the database called 'sources' and in that field is the following data: 'self, partner, family, loan'. On an update form I have a menu that I want each item selected. How do I achieve that?

Thanks
Translate
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
Explorer ,
Aug 22, 2008 Aug 22, 2008
LATEST
Is the question understood or perhpaps I should do a repost with a different subject? Anyone have any ideas?
Translate
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