duanniubeng2265
2016-11-20 13:12
浏览 463
已采纳

MySQL数据库中预先选择的下拉列表值

Though I have researched, I couldn't find any solution for this. I need to get the database value ("Default") as the pre-selected value of the drop down list.

<select name="listCustomer" id="listCustomer">
    <?php 
    $sql = mysqli_query($connection,"SELECT customer_name FROM customers");
    while ($row = mysqli_fetch_array($sql,MYSQLI_ASSOC)){
    echo "<option value=\"" .   $row['customer_name'] . "\">" . $row['customer_name'] . "</option>";}
    ?>
</select>

Can you please help me on this?

图片转代码服务由CSDN问答提供 功能建议

虽然我已经研究过,但我找不到任何解决办法。 我需要将数据库值(“Default”)作为下拉列表的预选值。

 &lt; select name =“listCustomer”id =“listCustomer  “&gt; 
&lt;?php 
 $ sql = mysqli_query($ connection,”SELECT customer_name FROM customers“); 
 while($ row = mysqli_fetch_array($ sql,MYSQLI_ASSOC)){
 echo”&lt; option  value = \“”。$ row ['customer_name']。“\”&gt;“  。  $ row ['customer_name']。  “&lt; / option&gt;”;} 
?&gt; 
&lt; / select&gt; 
   
 
 

您可以帮我解决这个问题吗? \ n

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题