gpt4 book ai didi

PHP "for"循环不正确循环

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:08 26 4
gpt4 key购买 nike

我在下面输入了“for”循环代码,它没有循环遍历我所有的 MYSQL 数据。相反,它仅循环遍历数据库中的第一行数据 ( shown circled in red in this attached screenshot ),并且不会显示我数据库中其他 4 本书的其余作者/书名/类别/年份/isbn 信息。

我在 Windows 10 机器上使用 XAMPP 3.2.2。如果您需要更多我的上下文代码,我可以提供。谢谢!

for ($j = 0; $j <$rows; ++$j);
{
$result->data_seek($j);
$row = $result->fetch_array(MYSQLI_NUM);

echo <<<_END
<pre>
Author $row[0]
Title $row[1]
Category $row[2]
Year $row[3]
ISBN $row[4]
</pre>
<form action="sqltest.php" method="post">
<input type="hidden" name="delete" value="yes">
<input type="hidden" name="isbn" value="$row[4]">
<input type="submit" value="DELETE RECORD"></form>
_END;
}

最佳答案

发生这种情况是因为您的循环有一个空语句 ;:

for ($j = 0; $j <$rows; ++$j); //<------ the semicolon !!

我确定这只是一个错字!请删除分号并尝试。

关于PHP "for"循环不正确循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38417255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com