如何判断所查的数据为空? array mysql_fetch_array ( resource result [, int result_type] )返回根据从结果集取得的行生成的数组,如果没有更多行则返回 FALSE返回false就是没有,while都不会运行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $result = mysql_query("select *,Count(*)as Total from newswhere id = ".$aid."",$link);while($data = mysql_fetch_array($result)){..............}-----------if(Total==0){木有数据} $num = mysql_num_rows($result)if($num==0){ echo "无数据";} $result = mysql_query("select * from newswhere id = ".$aid."",$link);while($data = mysql_fetch_array($result)){..............}if (!$data){..............} $result = mysql_query("select * from newswhere id = ".$aid."",$link);while($data = mysql_fetch_array($result)){..............}没有数据 $data 为 FALSE $result = mysql_query("select * from newswhere id = ".$aid."",$link);$myrow = MySQL_fetch_array($result);if ($myrow){}else{ //不存在该ID的数据} 没数据会报错 前面加@隐藏错误@$result = mysql_query("select * from newswhere id = ".$aid."",$link); $result = mysql_query("select * from newswhere id = ".$aid."",$link);$num=mysql_num_rows($result);//取得记录数if ($num==0) { echo "该数据记录不存在";}else { while($data = mysql_fetch_array($result)) { .............. }} 大家帮我看看这是什么问题 JS控制不同Frame问题 瞎说count函数对非数组变量的处理 MYSql 关于外键约束建立不了问题. 想问问这段代码为啥不成功 这个功能怎么实现 php中怎么样下载整个文件夹 帮我看看 我能够熟练的运行ASP,PHP,JSP,ISAPI进行WEB开发。 菜鸟提问。一条语句的详细解释。 简单的 include 问题。。。 一次查询,如何多次使用查询结果
while($data = mysql_fetch_array($result))
{
..............
}
-----------
if(Total==0){木有数据}
if($num==0)
{
echo "无数据";
}
while($data = mysql_fetch_array($result))
{
..............
}
if (!$data)
{
..............
}
while($data = mysql_fetch_array($result))
{
..............
}没有数据 $data 为 FALSE
$myrow = MySQL_fetch_array($result);
if ($myrow){}else{
//不存在该ID的数据
}
@$result = mysql_query("select * from newswhere id = ".$aid."",$link);
$num=mysql_num_rows($result);//取得记录数
if ($num==0) {
echo "该数据记录不存在";
}
else {
while($data = mysql_fetch_array($result))
{
..............
}
}