我正在为一个在线dvd租赁和预订系统编写网站代码,并尝试在下拉菜单中调用dvdid,它是我phpmyadmin数据库中dvd的主键和标题,但当我尝试调用其中的id时,它不起作用。任何帮助都将不胜感激。
<form name="FrmAmend" method="post" action="amenddvd2.php">
Select from the list below<br>
<select name="Film" title="Select DVD">
<option value="" selected disabled>Select DVD</option>
<?php
$result = mysqli_query($con, "SELECT `DVDID`, `Title` FROM tbldvd;");
$row = mysqli_fetch_assoc($result);
foreach ($result as $row) {
echo "<option value='" . $row['DVDID'] . $row['Title'] . "'>" . $row['DVDID'] . $row['Title'] . "</option>";
}
?>
</select><br>
<a href="menu.php"</a>Return To Main Menu<br>
<input type="submit" name="Submit" value="Select DVD">
</a>
</form>
1条答案
按热度按时间sczxawaw1#
你的问题是你收集数据的方式,你有以下几点;
while ($row = mysqli_fetch_assoc($result) {
DVDID Title
1 ABC
2 DEF
<a href="menu.php"Return To Main Menu
Return To Main Menu