我不知道为什么,一个应该是有限的循环,比如
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简单简单这里是很简单的pdo教程
$pdo = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8', 'username', 'password');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$query = $pdo->prepare("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC");
$query->execute();
$row=$articlequery->fetch(pdo::FETCH_ASSOC);
尝试这个。
$query = mysql_query("SELECT * FROM noticias WHERE deletada='0' ORDER BY id ASC");
while($noticia = mysql_fetch_array($query)){
echo $noticia['table_field'];
}