dongmao4486 2016-10-19 09:14
浏览 693
已采纳

MySQL返回一个空的结果,仍然显示为1

I have a query which is to check data from two different tables everything is working fine though. When i paste the query in cPanel then result is showing like this MySQL returned an empty result set (i.e. zero rows). (Query took 0.0005 sec)

but when i count the query in php it is returing 1 instead of 0 don't know why Here is my Sql query

  SELECT mobile, emailid
FROM tbl_users
WHERE mobile =9653878051
AND emailid = 'rawat@gmail.com'
GROUP BY mobile
UNION ALL SELECT mobile, email
FROM tbl_addusr
WHERE mobile =9653878051
AND email = 'rawat@gmail
.com'
LIMIT 0 , 30

and i am counting it like this i am storing the sql result in data variable

     $result = mysql_num_rows($data);

  echo count($result)>0?1:0;  

and it is resulting 1 instead of 0

  • 写回答

4条回答 默认 最新

  • doutui2883 2016-10-19 09:23
    关注

    You do not need to count anything. mysql_num_rows gives you the number of rows.

    Use like this:

    $result = mysql_query($query);
    echo  mysql_num_rows($result);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失