我从插入表单的组合框中选择一个数据并存储在数据库中。 然后我想在编辑表单上显示该数据,但是如果我想更改数据,我可以再次从组合框中选择..您能帮我吗?谢谢
此代码在我的编辑表单上:
<select class="select" name="category">
<option>Choose Category</option>
<?php
require_once './db_freelancer.php';
$get_data = mysqli_query($mysqli, "select * from project_category");
while($category = mysqli_fetch_array($get_data)){
echo " <option value=".$category['category_id'].">".$category['category_name']."</option>";
}
?>
</select>
答案 0 :(得分:0)
您可以尝试下面的代码。...根据您的数据结构编辑此代码
$member_category = $memberdata['category_id']; // Retrieve member's category from database.
<select class="select" name="category">
<option>Choose Category</option>
<?php
require_once './db_freelancer.php';
$get_data = mysqli_query($mysqli, "select * from project_category");
while($category = mysqli_fetch_array($get_data)){
echo '<option value="'.$category['category_id'].'" '.(($category['category_id']==''.$member_category.'')?'selected="selected"':"").'>'.$category['category_name'].'</option>';
} ?>
</select>