且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在mysqli中编辑记录时,在下拉列表中显示先前选择的值

更新时间:2023-01-27 11:03:24

工作代码:

您可以使用所选的选项。
假设您有两种形式:
添加形式。
更新表单。
首先通过GET方法发布url中的值,以便您可以访问另一个页面中的字段值。

You can use the selected option. Suppose if you have two forms: Add form. Update form. First post the values in url through the GET method so that you can access the field value in another page.

<select name = "field_name">
<option value="<?php echo $_GET["field_name"]; ?>" selected > <?php echo 
$_GET["field_name"]; ?> </option>
{
 //you can add your dropdown condition here if you are fetching an array
}
</select>