我希望我的程序在我的页面上的下拉菜单中的列表中列出来自 mysql 表的数据。这是我的代码:
<fieldset>
<legend> Selecteer uw Categorie </legend>
<label for ="Categorie"> Categorie </label>
<select name ="Categorie" id="Categorie">
<datalist id ="Categorie">
<Option Value="Router">Router</option>
<Option Value="Switch">Switch</option>
<Option Value="Toestel">Toestel</option>
<Option Value="Basisstation">Basisstation</option>
<Option Value="Repeaters">Repeaters</option>
<Option Value= <?php
$con=mysqli_connect("localhost","root","admin","inventarisdb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Categorien");
while($row = mysqli_fetch_array($result))
{
echo "<ul>";
echo "<li>" . $row['Categorieen1'] . "</li>";
echo "</ul>";
}
echo "</table>";
mysqli_close($con);
?>
</option>
</select>
</datalist>
</fieldset>
这段代码完美运行,它查找我需要的数据并将其发布在下拉列表中但所有内容都发布在一行中..我希望它在彼此下方列出..请帮助我!