我对这段代码有一个问题,因为第二个 while 循环只在第一次通过代码时运行,然后它也使得 $row['id'] 没有得到一个值。你能帮我弄清楚我哪里出错了吗?
$result = mysqli_query($con,"SELECT * FROM faq ORDER BY `order`");
$result2 = mysqli_query($con,"SELECT * FROM sections ORDER BY `order`");
while($row = mysqli_fetch_array($result))
{
echo '<form action="../../includes/faqupdate.php" method="post" style="margin:40px;">';
echo '<input type="text" name="order" style="width:20px;text-align:center;" onclick="this.value=\'\';" onfocus="this.select()" onblur="this.value=!this.value?\'' . $row['order'] . '\':this.value;" value="' . $row['order'] . '">';
echo '<input type="text" name="heading" onclick="this.value=\'\';" onfocus="this.select()" onblur="this.value=!this.value?\'' . $row['heading'] . '\':this.value;" value="' . $row['heading'] . '">';
echo '<select name="section">';
$section = $row['section'];
while($row = mysqli_fetch_array($result2)) {
$sectionname = $row['sectionname'];
if ($sectionname == $section) {
echo '<option value="' . $sectionname . '" selected="selected">' . $sectionname . '</option>';
} else {
echo '<option value="' . $sectionname . '">' . $sectionname . '</option>';
}
}
echo '</select>';
echo '<input type="text" name="id" style="width:20px;background-color:#CCC;text-align:center;" value="' . $row['id'] . '" readonly>';
echo '<textarea name="content" cols="98" rows="10">' . $row['content'] . '</textarea>';
echo '<input type="submit" name="submission" value="Update">';
echo '<input type="submit" name="submission" value="Delete">';
echo '</form>';
}