PHP Multiple Drop-down Folder Submit to MySQL

Could not find good information on how to do this, so I thought I'd add it here. How to capture selected data from html dropdown with several options using php and send to database. I need a separate row for each choice.

I would be happy just knowing how to capture data and put it in an array.

+3
source share
1 answer

It goes to the array, in fact!

<form action="myscript.php" method="POST">
<select name="colors[]" multiple="multiple" size="2">
<option>Red</option>
<option>Blue</option>
<option>Green</option>
<option>Orange</option>
</select>
<input type="submit" value="Go!"> 
</form>

Then on the server side there $_POST['colors']will be an array with the selected values.

The key point here is to use parenthesized notation in the name so that PHP knows what to expect from the array.

PHP.

, .

+7

Source: https://habr.com/ru/post/1709659/


All Articles