我使用while填充数据库的下拉列表。我在拉名字。页面将填充列表就好了。当我提交表单时,while循环中的数据不会传递到第二页。
发送页面的代码:
<?php
include 'connect.php';
$TickID = $_POST['ticket'];
$EID = $_POST['employee'];
$techs = mysql_query("SELECT TechID,fname FROM technician") or die(mysqli_error());
echo "<form action='assign-send.php' method='post'>";
echo "Who would you like to assign this ticket to? <select><option></option>";
while($row = mysql_fetch_assoc($techs, MYSQL_ASSOC)){
echo "<option name=\"Tech" . $row['TechID'] . "\" value=" . $row['TechID'] . ">" . $row['fname'] . "</option>";
}
echo "</select> ";
echo "<input type='hidden' name='TickID' value=" . $TickID . ">";
echo "<input type='hidden' name='EID' value=" . $EID . ">";
echo "<input type='submit' name='submit' value='Assign Ticket'>";
echo "</form>";
?>
收到页面的代码:
<?php
$TechID = $_POST['TechID'];
$TickID = $_POST['TickID'];
$EID = $_POST['EID'];
echo $TechID . $TickID . $EID;
// mysql_query("INSERT INTO assignment (`TechID`, `TickID`, `EID`)
// VALUES ('$TechID', '$TickID', '$EID')") or die(mysql_error()); //store information as variable
// header(location:'manage_assign.php');
?>
目前只发送TickID和EID值,因为它们是从上一页检索的,但是来自while循环内的TechID数据没有成功。
答案 0 :(得分:1)
这是因为您的<select>
没有name
代码。
应该是:
<select name="TechID">
<option></option>
</select>
您现在可以通过以下方式访问所选选项的值:
$my_selected_option = $_POST['TechID']; //The option value selected
答案 1 :(得分:0)
html SELECT
的属性为name
,OPTION
没有。
<select name="Tech">
<option value="rowId01">rowName01</option>...
</select>