我想创建一个下拉列表,允许用户选择从数据库中提取的值。当基于所选值更新页面时,该选项将恢复为“原始”默认选项。当页面更新时,如何允许选择的值保存并保留?
// Drop Down Menu to choose Session
if (isset($_POST['action']))
{
$action = $_POST['action'];
$session = $_POST['session'];
}
else
{
$action = "";
if (!isset($_POST['session']))
{
$session = "";
}
else
{
$session = $_POST['session'];
}
}
?>
<form name='update' action='emailinquiry_webinarnew.php' method='POST'>
Session:
<select name='session'>
<?php
$query = "SELECT distinct session FROM web_attendees";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
echo "<option>".$row['session']."</option>";
}
?>
</select>
<input type='submit' name="ViewButton" value='View'/>
</form>