這是某個站點的管理面板的代碼。客戶提出的約會將顯示在此頁面中。管理員將能夠根據可用性change
約會。提交由循環生成的表單的特定行
<?php
while($row = mysqli_fetch_assoc($result)){
?>
<form action="adminEdit.php" method="POST">
<tr>
<td><input type="text" id="name" value="<?php echo $row['Name'];?>"></input></td>
<td><input type="text" id="address" value="<?php echo $row['Address'];?>"></input></td>
<td><input type="text" id="phone" value="<?php echo $row['Phone'];?>"></input></td>
<td><input type="text" id="license" value="<?php echo $row['Car_License_No'];?>"></input></td>
<td><input type="text" id="engine" value="<?php echo $row['Car_Engine_No'];?>"></input></td>
<td><input type="text" id="date" value="<?php echo $row['Date'];?>"></input></td>
<td><input type="text" id="mechanic" value="<?php echo $row['Mechanic'];?>"></input></td>
<td><input type="submit" name="submit" value="Change"/></td>
</tr>
</form>
<?php
}
?>
在這裏,每行數據都有一個對應的按鈕,它將用於更改或修改該特定行的記錄。一旦管理員更改了特定的約會,它應該在數據庫中更新。
我的問題是,所有的行都是通過while循環生成的。現在如何訪問特定行,當點擊該特定行的change
按鈕時?當行由循環產生時,我贏得了t be able to access them by
名稱or
id because all of them will have the same
名稱and
id`。
搜索了相關問題,但沒有一個與我的場景匹配。這將有助於獲得答案。提前致謝。
非常感謝你爲你準確的答案。只是問,如果我在每個輸入中放置一個隱藏值,是否可以有一種方法? –
您可以將隱藏值放入表單(每行)的每個循環中,例如ID併發送提交。 – James