我需要使用基本查询填充下拉列表,但无法。我之前意外填充了它,但我需要更改一些小的东西,它滚雪球失控,我无法再产生填充的下拉列表。
<html>
<ul id="navigation">
<li><a href="index.php">Home</a></li>
<li><a href="view.php">Available Content</a></li>
<li><a href="topic.php">Topics</a></li>
<li><a href="login.php">Login</a></li>
<li><a href="sign_up.php">Sign-Up</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
<form method="post" action="topicChosen.php">
<select name="selectitem">
<?php
require_once 'needed.php';
if (isset($_SESSION["p_id"])) {
if ($stmt = $mysqli->prepare("Select distinct topic from topic")) {
$stmt->execute();
$stmt->bind_result($var1);
while ($stmt->fetch()) {
echo "<option value=\"$var1\">$var1</option>";
}
}
} else {
//if user not logged in
}
?>
</select>
<input type="submit" value="send">
</form>
</html>