tags:

views:

46

answers:

2

Hi,

can anyonme give me an idea of how to catch (using PHP) multiple values from a multi 'selectbox' please?

<select name="auto_issue_update" multiple>
<option>1</option>
<option>2</option>
</select>
+3  A: 

Make the name have brackets on the end to distinguish it as an array

<select name="auto_issue_update[]" multiple>

Then on the PHP side, you would do something like (if you're using POST for your form. swap POST for GET if you're not)

$auto_issue_update = $_POST['auto_issue_update'];
foreach ($auto_issue_update as $a){echo $a.' was selected <br />';}
tschaible
how do I catch it on the other end ( .php file?)
JPro
sorry for this, but I want to assign the selected values to different variables.
JPro
can you provide a bit more detail in your question. What variables do you want to assign the results to? Are there any naming conventions for them?
tschaible
What I mean is I have to store these selected values back in the database (MYSQL). So I am not sure how to do that. Assigning the values to variables seems easy to me.
JPro
Again, we need some more information. What does your database schema look like? How are you expecting the values to be stored? 1 value per row, values get spread across multiple columns, etc.
tschaible
I have a table like this : ID, Selected_Values, ResultSo all the <select> values should go into the 'Selected_Values' with some comma imploding. When I extract the values I will use explode to separate them.
JPro
+3  A: 

define your select this way :

<select name="auto_issue_update[]" multiple>

For PHP, I'm assuming that you POST your form :

$myresult = $_POST['auto_issue_update'];
foreach($myresult as $result) { ... }
Soufiane Hassou