Forums

Multiselect array and DB storage

giacall99 06 Apr, 2010
Hi to all. I'm new in the forum.. and i'm italian.. sorry for my english..

I need a little help..

I created a form with three fields:
1)input text
2)radio button
3)a multiselect dropdown with this code:

Code: Select all
<select name="operatore[]" size="5" multiple="multiple">



The form correctly saves the data in the database.
But, there is a way to save a record for each option selected in dropdown multiselect?

Example:
now the table is:
id > 1
name > paolo (from input text)
sex > male (from radiobutton)
operatore > 1, 2, 3 (from the dropdown multiselect array operatore[])

i would like:
id > 1
name > paolo (from input text)
sex > male (from radiobutton)
operatore > 1 (the first value of the array)

id > 2
name > paolo (from input text)
sex > male (from radiobutton)
operatore > 2 (the second value of the array)

id > 3
name > paolo (from input text)
sex > male (from radiobutton)
operatore > 3 (the third value of the array)

It's possible??

Thank's a lot a sorry for my english...😟
GreyHead 07 Apr, 2010
Hi giacall99,

Can be done but not automatically by ChronoForms - you just need to turn off the DB Connection and write the MySQL query by hand in one of the OnSubmit Code boxes.

Bob
giacall99 07 Apr, 2010
Hi Bob.

Thank's for the replay. I had thought of this solution..

But when you say

..and write the MySQL query by hand in one of the OnSubmit Code boxes

you mean to write the query in PHP in tab "form code" > "onSubmit Events Code" > "On Submit code - before sending email:"?

Is this the right position for te code?

Thank's

Luca
GreyHead 07 Apr, 2010
Hi giacall99,

Yes, either that or the 'After' box.

The only thing to be careful of is that code in the Before Box is only executed if 'Send Emails' is set to 'Yes' on the Form General tab. (Code in the After box is always executed.)

Bob
giacall99 07 Apr, 2010
Ok Bob.. Thank's for the information.

I tray to write the code for the query..
This topic is locked and no more replies can be posted.