我可以将表单发布到数据库中但是我只获得了0作为select标记的值,我如何获得数据库中每个选择选项的值?
<select class="span6" name="test_name">
<?php
include ('include/connect.php');
$query1 = "SELECT test_name FROM mst_test ORDER BY test_name ASC";
$result = mysql_query($query1);
while(list($test_name)=mysql_fetch_array($result))
{
echo "<option value ='$test_name' selected>$test_name</option>";
}
?>
</select>
答案 0 :(得分:0)
<select class="span6" name="test_name">
<?php
include ('include/connect.php');
$query1 = "SELECT test_name FROM mst_test ORDER BY test_name ASC";
$result = mysql_query($query1);
while ($row = mysql_fetch_array($result)) {?>
<option value ="<?php echo $row['test_name'];?>"><?php echo $row['test_name'];?></option>
<?php }?>
</select>
答案 1 :(得分:0)
<select class="span6" name="test_name">
<option value="">Please select</option>
<?php
include ('include/connect.php');
$query1 = "SELECT test_name FROM mst_test ORDER BY test_name ASC";
$result = mysql_query($query1);
while ($test_name = mysql_fetch_assoc($result)) {
echo "<option value='{$test_name['test_name']}'>{$test_name['test_name']}</option>";
}
?>
</select>