2
不足表單提供了一系列使用選擇表單選擇的選項。當從$ _POST數組中檢索值時,雖然傳遞了正確的ID,但季節值似乎只是表單中的最後一個值。從HTML表單傳遞不正確的值
我已經檢查過我的代碼,聯盟並沒有在其他地方更新,據我所知。
我確定我錯過了一些明顯的東西,但無法弄清楚!
<form method = 'post' action = 'index.php?choice=matcht&stage=1'><table width = '50%' border = '1'><thead><tr>
<th>Select</th>
<th>League</th>
<th>Season</th>
</tr></thead>
<tr><td><input type = 'radio' name = 'id' value = '1' ></td>
<td><input type = 'text' name = 'league' value = 'MLB21' readonly></td>
<td><input type = 'text' name = 'season' value = '12' readonly></td>
</tr>
<tr><td><input type = 'radio' name = 'id' value = '25' ></td>
<td><input type = 'text' name = 'league' value = 'MLB21' readonly></td>
<td><input type = 'text' name = 'season' value = '13' readonly></td>
</tr>
<tr><td><input type = 'radio' name = 'id' value = '49' ></td>
<td><input type = 'text' name = 'league' value = 'MLB21' readonly></td>
<td><input type = 'text' name = 'season' value = '14' readonly></td>
</tr>
<tr><td><input type = 'radio' name = 'id' value = '73' ></td>
<td><input type = 'text' name = 'league' value = 'MLB21' readonly></td>
<td><input type = 'text' name = 'season' value = '15' readonly></td>
</tr>
<tr><td><input type = 'radio' name = 'id' value = '97' ></td>
<td><input type = 'text' name = 'league' value = 'MLB21' readonly></td>
<td><input type = 'text' name = 'season' value = '16' readonly></td>
</tr>
<tr><td colspan = '3' align = 'center'><input type = 'submit' name = 'go' value = 'GO'></td></tr>
</table>
</form>
這裏是PHP生成HTML:
$sql='SELECT `TeamID`, `League`,`Season` FROM teams WHERE `FranchiseID` = 0 GROUP BY `League`,`Season` ORDER BY `League` ASC ,`Season` ASC ';
$unmatched = $db2->get_results($sql);
if ($db2->num_rows>0) {
echo "<form method = 'post' action = 'index.php?choice=matcht&stage=1'>";
echo "<table width = '50%' border = '1'>";
echo "<thead><tr>\n";
echo "<th>Select</th>\n";
echo "<th>League</th>\n";
echo "<th>Season</th>\n";
echo "</tr></thead>\n";
foreach ($unmatched as $unmatch)
{
// Access data using object syntax
echo "<tr>";
echo "<td><input type = 'radio' name = 'id' value = '$unmatch->TeamID' ></td>\n";
echo "<td><input type = 'text' name = 'league' value = '".$unmatch->League."' readonly></td>\n";
echo "<td><input type = 'text' name = 'season' value = '".$unmatch->Season."' ></td>\n";
echo "</tr>\n";
}
echo "<tr><td colspan = '3' align = 'center'><input type = 'submit' name = 'go' value = 'GO'></td></tr>\n";
echo "</table>\n";
echo "</form>\n";