Hope you can advise with this one. I have a long form in php, a portion of which is only displayed using php and echo depending on user variables previously obtanted from a MYSQL database. This is a snippet of testing code below can anyone advise on how I can get a list/menu created by php echo to display values previously entered during the forms validation process?
<html> <? $selected = $_POST['list']; echo $selected; ?> <form name="form1" method="post" action="<?php $_SERVER["PHP_SELF"]; ?> "> <? echo '<select name="list" id="list"> <option value=';if ($_POST['list'] == "1") echo "SELECTED";'>item1</option> <option value="2">item2</option> <option value="3">item3</option> </select>'; ?> <input type="submit" name="Submit" value="Submit"> </p> </form> </html>
Any advice or pointers greatly appreciated.