PHP:为什么不能在mysqli_fetch_array()结果上循环两次? [英] PHP: why can't I loop twice on mysqli_fetch_array() results?
本文介绍了PHP:为什么不能在mysqli_fetch_array()结果上循环两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从mysql数据库中检索一些数据.有两个循环使用相同的结果集.
I'm retrieving some data from a mysql database. There are two loops which uses the same result set.
while ($row = mysqli_fetch_array($newsQuery)) {
echo "<a href='news-article.php?articleId=" .$row["news_id"]."' class='list-group-item active'>".$row["news_title"]."</a>";
}
此循环以成功结束.然后在同一页面中,我有以下循环.
This loop ends with success. then in the same page I have the following loop.
while ($row = mysqli_fetch_array($newsQuery)) {
echo $row["news_content"];
}
即使表中有内容,此循环也不会返回任何内容.当我在第一个循环中尝试时.内容正确显示.关于我在做什么错的任何想法.
This loop doesn't return anything even if there are content in the table. When I try it in the first loop. the content is displayed correctly. Any idea on what I'm doing wrong.
推荐答案
查看全文