it is easy to create a form that will allow a user to select multiple values and then get the data that was entered. What I want to know is how to recreate that form based on the information in the database? ie Edit the data.
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<select name="test[]" multiple="multiple">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
</select>
<input type="submit" value="Send" />
</form>
<?php
$test=$_POST['test'];
if ($test){
foreach ($test as $t){echo 'You selected ',$t,'<br />';}
}
?>
Say values two and foru were seleted in the original data. How would I recreate the form to edit the data like the code below:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<select name="test[]" multiple="multiple">
<option value="one">one</option>
<option selected value="two">two</option>
<option value="three">three</option>
<option selected value="four">four</option>
<option value="five">five</option>
</select>
<input type="submit" value="Send" />
</form>
Initially I want the code for add and edit to work. Eventually I want to be able to enter various multiple select options in a form and to edit them.