SELECT using php

0

Good night how do I assign a value to a variable where the value comes from select? but there are several select form, I want to get the value of the select that is selected.

    
asked by anonymous 29.10.2017 / 23:20

1 answer

2

If I understand correctly, you want to get values of a select multiple there from form , right?

In this case you should interact with array in php.

HTML:

<form action="pagina.php" method="GET"> 
 <select multiple name="select_multiple[]"> 
  <option value="Exemplo1">Exemplo1</option> 
  <option value="Exemplo2">Exemplo2</option> 
  <option value="Exemplo3">Exemplo3</option> 
  <option value="Exemplo4">Exemplo4</option> 
  <option value="Exemplo5">Exemplo5</option> 
 </select> 
</form>

PHP:

$select_multiple = $_GET['select_multiple'];
for ($i=0; $i < count($select_multiple); $i++){
    echo $select_multiple[$i];
}

Now if it is a select normal, the value is already set in the same way as fields text , checkbox , radio , etc.

    
30.10.2017 / 00:29