【发布时间】:2020-12-10 10:27:40
【问题描述】:
我想编辑特定行(当然是您选择的行),如下所示: enter image description here
这适用于大多数行,但我对使用下拉列表提交的行有问题。当我要编辑时,我希望我可以使用另一个下拉列表更新该行,并且首先选择 Row 的值,以便您可以清楚地看到其中的值(也许您不想从下拉列表中更改值,但您也必须更改它,因为未选择行中的值: 为了更好地理解: enter image description here
假设在“副手”领域是微软。现在我想更改“名称”行,但是因为这里的下拉列表向我显示了下拉列表的第一个值,所以我每次都必须再次将其更改为 microsoft。
这是我的下拉列表(在提交文件和更新文件中):
<div class="form-group">
<label for="formGroupExampleInput2">Lieferant</label>
<?php
$sql5= "SELECT lieferantID, lieferantname FROM lieferant";
$result5 = $connection ->query($sql5);
if ($result5->num_rows > 0) {
echo"<select name='lieferantID'>";
while ($row2 = $result5 ->fetch_assoc()){
echo"<option value='" . $row2['lieferantID']. "'>" . $row2['lieferantname'] . "</option>";
}
echo"</select>";
}
?>
</div>
这里是更新查询:
$update=mysqli_query($connection,"UPDATE kunde_projekt SET kundenname_projekt='$kundenname_projekt', standort='$standort', info_uebergabe='$info_uebergabe', kstnr='$kstnr', InvestPSPID='$investpspid' WHERE kundeprojekt_id='$kundeprojekt_id'");
这里是“kstnr”和“kostenstelle”提交到更新文件的按钮:
<td> <button class="btn-primary btn"> <a href="updateliste.php? kstnr=<?php print $row['kstnr']; ?>&kostenstelle=<?php print $row['kostenstelle']; ?>" class="text-white"> Update </a> </button> </td>
感谢您的帮助!
【问题讨论】:
-
后续“行”可能需要“ajax”,这样它就不会全部在 html/dom 中预渲染。