Php mysql_fetch_array()执行无限循环
我不知道为什么,循环应该是有限的,比如Php mysql_fetch_array()执行无限循环,php,mysql,loops,Php,Mysql,Loops,我不知道为什么,循环应该是有限的,比如 while ($noticia = mysql_fetch_array(mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC"))) { // echo $noticia['blabla']; } 正在执行无限循环,而页面不加载 为什么会这样?可以通过 $qry = mysql_query("SELECT * FROM noticias WHERE del
while ($noticia = mysql_fetch_array(mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC")))
{
// echo $noticia['blabla'];
}
正在执行无限循环,而页面不加载
为什么会这样?可以通过
$qry = mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC")
while ($noticia = mysql_fetch_array($qry ))
{
// echo $noticia['blabla'];
}
但不推荐使用mysql.*
函数,因此请使用pdo或mysqli
pdo是一个简单的
试试这个
$query = mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC");
while($noticia = mysql_fetch_array($query)){
echo $noticia['table_field'];
}
因为在每次执行查询时,所以每次获得数据时,mysql都不推荐使用,所以请使用
pdo
或mysqli
mysql.*
不推荐使用,所以不要使用suggest@SergioToledoPiza如果此答案对您有帮助,您可以通过单击投票窗格下方的右侧标记来接受此答案
$query = mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC");
while($noticia = mysql_fetch_array($query)){
echo $noticia['table_field'];
}