Working with listbox and php
Free Scripts :: PHP :: PHP and Forms :: Working with listbox and php
Website: http://www.salman.be
- How to process listbox or multiple select box with php.
- How to get listbox values with php.
- Working with php and multiple value select box.
This script process listbox values sent from a form. We have 2 php pages. At Forms.php we have a form with listbox and a submit a button. Once we click submit button after selecting few values, the page submits values to Save.php. Then we get all listbox selected value with the help of for loop.
Form.php
<form method="post" action="Save.php">
<select name="country[]" multiple="multiple">
<option value="Belgium">Belgium</option>
<option value="France">France</option>
<option value="Germany">Germany</option>
<option value="Holland">Holland</option>
<option value="Greece">Greece</option>
</select>
<input type="Submit" value="Submit" />
</form>
Save.php
if(!empty($_POST['country'])){
for ($i=0; $i < count($_POST['country']);$i++) {
echo $_POST['country'][$i] . ", ";
}
}
Output:
Belgium, Germany,




