我想在同一页上的不同while循环中多次使用同一条sql语句,但是当我执行相同操作时,它不在第二页中显示数据
这是我的示例代码
<?php
require_once "../core/init.php";
include "includes/header.php";
include "includes/navigation.php";
$sql = "SELECT * FROM categories ORDER BY category";
$result = $db->query($sql);
$errors = array();
?>
<h2>
Categories
</h2>
<form action="categories.php" method="post">
<h3>
Add New Category
</h3>
<select name="parent_drop" id="parent_drop">
<?php while($categories = mysqli_fetch_assoc($result)): ?>
<option name="parent_id" id="parent_id" value="parent_id"> Parent Names</option>
<?php endwhile; ?>
</select>
<br>
<br>
<input type="submit" name="add_category" value="Add Category" class="btn btn-success">
<br>
<br>
</form>
<div>
<?php while($categories = mysqli_fetch_assoc($result)): ?>
piece of code
<?php endwhile; ?>
</div>
<?php include "includes/footer.php" ?>