gpt4 book ai didi

php - 在php html中显示从mysql到dropdownbox的具体信息。

转载 作者:行者123 更新时间:2023-11-29 11:28:45 25 4
gpt4 key购买 nike

这些是我从数据库获取信息的代码。因此,状态是我的数据库中的“感兴趣”或“不感兴趣”的状态。

while($row= mysqli_fetch_array($result))
{
$ID =$row['Particulars_ID'];
$name = $row['Name'];
$number =$row['Number'];
$status =$row['Status'];
$remarks =$row['Remarks'];
}

如果我的数据库显示此人不感兴趣,我想回显值“不感兴趣”。然而,从我下面的代码来看,无论我点击哪个人,它总是显示感兴趣。

echo "<select name = 'status', id = status>
<option value='Interested'>Interested</option>
<option value='Not Interested'>Not Interested</option>
</select><br>";

最佳答案

第一 - 您不需要在选择中使用逗号,第二 - 确保这是唯一具有状态 id 的元素,第三 - 只需检查每个选项中的 $status 值,如果是,则回显所选内容。

echo "<select name = 'status' id = 'status'>
<option value='Interested'";
if($status == "Interested"){echo " selected";}
echo">Interested</option>
<option value='Not Interested' ";
if($status == "Not Interested"){echo " selected";}
echo">Not Interested</option>
</select><br>";

关于php - 在php html中显示从mysql到dropdownbox的具体信息。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37770341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com