我是php和下拉菜单的新手,我的查询有效,但在显示时总是缺少输入的最后一行。所以如果输入两行,下拉列表只会显示一行?我做错了什么?
<?php
require("********");
$query=mysql_query("select * from types");
echo "<table >
<tr align='left'>
<th><font color='red'>Description</th>
</tr>";
$options='';
while($dbfield = mysql_fetch_array($query))
{
$options .= '<option>'.$dbfield['Description'].'</option>';
echo "
<form method='post'>
<td><select name='Description'><? echo $options; ?></select>
</tr>";
答案 0 :(得分:1)
}
)您的while
循环。 mysql_
函数也已弃用。
<?php
require("********");
$query=mysql_query("select * from types");
echo "<form method='post'>
<table>
<tr align='left'>
<th><font color='red'>Description</th>
</tr>";
$options='';
while($dbfield = mysql_fetch_array($query)) {
$options .= '<option>'.$dbfield['Description'].'</option>';
}
echo "<tr>
<td><select name='Description'><? echo $options; ?></select>
</tr>";