感谢您的所有建议!我正在列出未设置为"当月和#34;进入下拉菜单/选择菜单,以便将其他月份设置为可用于操作。我得到了该列表,但它填充了下拉列表,但是没有将该值传递给更新。我非常困惑或者缺少非常小的东西。
以下是查询:
if (isset($_POST['addMonth'])) {
$addmonth = $_POST['addmonth'];
//open additional months
$query_open_additional = "UPDATE reimbmonths SET reimb_open = 1 WHERE monthname = '$addmonth' ";
$query_current = "SELECT * FROM reimbmonths WHERE reimb_open = 1";
$result_current = mysql_query($query_current) or die ('Query failed: ' . mysql_error() . "<br />\n$sql");
$num_current = mysql_num_rows($result_current);
echo "Added another month: " . $addmonth;
}
这是HTML / PHP:
<h3>Open additional months</h3>
<form id="add-months" action="" method="post" onsubmit="window.location.reload() onchange="addMonth();"">
<select name="addmonth" id="addmonth">
<option <? if (empty($_POST["addmonth"])) { echo 'selected';} ?> disabled> --- Choose a Month --- </option>
<?
$i = 0;
while ($i < $num_months) {
$month_to_add = mysql_result($result_select_closed,$i,"monthname");
?>
<option value="<? $month_to_add ?>" <? if($_POST["addmonth"] === '$month_to_add') { echo 'selected';} ?>><? echo ucwords($month_to_add) ?></option>
<?
$i++;
}
?>
</select>
<input class="submit_btn" type="submit" name="addMonth" value="Set Month"/>
</form>