返回 mySQL 结果集时创建动态下拉菜单 [英] Creating a dynamic drop down menu when returning a mySQL result set

查看:31
本文介绍了返回 mySQL 结果集时创建动态下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个结果集从 mySQL 数据库返回到一个使用 5 列的表中.到目前为止,该表显示了正确的字段数据.我想知道我应该如何为每一行创建一个下拉菜单?这将是名为状态"的第 6 列,由三个值组成,这些值将改变行的外观.另一件事要提到的是状态"不会链接到数据库.这是我当前的代码:

I am returning a result set from a mySQL database into a table using 5 columns. So far so good the table is displaying the correct field data. I would like to know how I should go about creating a drop down menu for each row? This will be the 6th column named 'Status' and will consist of three values which will change the appearance of a row. Another thing to mention is that the 'Status' will not be linked to the database. Here is my current code:

<?php
$result = mysql_query("SELECT * FROM somewhere")
or die (mysql_error());
?>
<table class="table1" >
<h4>Orders</h4>
<tr>
<th>Number</th>
<th>Date</th>
<th>Ordered By</th>
<th>Supplier</th>
<th>Price</th>
<th>Status</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['Orderno'];
echo "</td><td>";
echo $row['Orderdate'];
echo "</td><td>";
echo $row['Orderedby'];
echo "</td><td>";
echo $row['Supplier'];
echo "</td><td>";
echo $row['totalprice'];
echo "</td><td>";
echo $row['Status'];
echo "</td></tr>";
}
echo "</table>";
?>

推荐答案

<select>
    <?php
    while($row=mysql_fetch_array($result)){
     ?>
     <option value = "<?php echo $row['Orderno']?>">
          <?php $row['other']?>
     </option>
     <?php
     }
     ?>
</select>

这只是示例.您可以根据自己的需求使用

This is only sample. You can use according to your requirements

这篇关于返回 mySQL 结果集时创建动态下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆