如何破坏块中的字符串值
include 'conn.php';
$query="SELECT defaultvalue FROM meta WHERE fieldid='grade' AND tableid='student'";
$result= mysqli_query($con,$query);
while($row=mysqli_fetch_array($result)){
echo "<option value='".$row['defaultvalue']."'>";echo $row['defaultvalue']; echo "</option>";
}
它的节目如
I II III IV V VI VII VIII XI X
我想显示此字符串值Dropdown 像这样
<select>
<option>I</option>
<option>II</option>
<option>III</option>
<option>IV</option>
<option>V</option>
etc
</select>
答案 0 :(得分:2)
您缺少<select>
标记。您的更新代码如下。
<?php
include 'conn.php';
$query="SELECT defaultvalue FROM meta WHERE fieldid='grade' AND tableid='student'";
$result= mysqli_query($con,$query);
echo '<select>';
while($row=mysqli_fetch_array($result))
{
echo "<option value='".$row['defaultvalue']."'>";echo $row['defaultvalue']; echo "</option>";
}
echo '</select>';
?>
答案 1 :(得分:1)
include 'conn.php';
$query="SELECT defaultvalue FROM meta WHERE fieldid='grade' AND tableid='student'";
$result= mysqli_query($con,$query);
echo "<select>";
while($row=mysqli_fetch_array($result))
{
echo "<option value='".$row['defaultvalue']."'>".$row['defaultvalue']."</option>";
}
echo "</select>;
答案 2 :(得分:1)
您缺少选择标记。你应该在开始循环之前打开select
标签
include 'conn.php';
$query="SELECT defaultvalue FROM meta WHERE fieldid='grade' AND tableid='student'";
$result= mysqli_query($con,$query);
echo "<select>";
while($row=mysqli_fetch_array($result)){
echo "<option value='".$row['defaultvalue']."'>".$row['defaultvalue']."</option>";
}
echo "</select>";