I have a multiple select dropdown field in html which has to return multiple values but it is returning only single value.
<select name="select[]" multiple>
<OPTGROUP label="cars">
<option value="car1">car1</option>
<option value="car2">car2</option>
<option value="car3">car3</option>
</OPTGROUP>
<OPTGROUP label="bikes">
<option value="bike1">bike1</option>
<option value="bike2">bike2</option>
<option value="bike3">bike3</option>
Below is the PHP to return the multiple values that are selected:
$select = mysqli_real_escape_string($link, $_POST['select']);
Thanks in advance.
_POST['select']?$_POST['select']is an array. You can't domysqli_real_escape_string()on an array, as it expects param 2 to be a string. You need to loop over each value to do escape, without overwriting the previous value.