0

I've got next situation:

I have multiple select boxes (that can select multiple choices) and i need that in php to be processed.

A code is next:

<select name="selectusers[]"  multiple>
	<option value="1">John</option>
	<option value="2">Smith</option>
</select>
<select name="selectusers[]"  multiple>
	<option value="1">John</option>
	<option value="2">Smith</option>
</select>
<input type="submit" value="Send" />

So now, in PHP I do the general foreach

<?php
    foreach($select_users as $users){
        ...
    }
?>

But each time I do foreach loop, and i print_r($select_users); inside of foreach, it gives me same result like:

Array([0]=>Array([0]=>30)[1]=>Array([0]=>33))
Array([0]=>Array([0]=>30)[1]=>Array([0]=>33))

What should I do?

Thank you.

2
  • that form doesn't make sense, there's two select boxes with both multiple attributes why not just one select box, you could select both John and Smith selections in one select box anyway Commented Mar 26, 2015 at 23:30
  • Because I'm appending more selecting boxes combined with text box (named title) and every title have it's users. Commented Mar 26, 2015 at 23:33

1 Answer 1

1

You need to change the name of your select:

<select name="selectusers[]"  multiple>
	<option value="1">John</option>
	<option value="2">Smith</option>
</select>
<select name="selectusers2[]"  multiple>
	<option value="1">John</option>
	<option value="2">Smith</option>
</select>
<input type="submit" value="Send" />

Try this.

Sign up to request clarification or add additional context in comments.

2 Comments

Is it anyhow possible to use same name?
Thank you, I've made it like that somehow.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.