duanleiming2014 2015-01-19 03:21
浏览 34

如何使用limit检查mysql中的数据?

How to check data in mysql using limit ?

When load this code (will check data in row id 2) , it's echo requests field

Why not echo not requests field

this is test_table:

________________________________
|  id  |  pro_id  |  requests  |
|  1   |  11111   |     0      |
|  2   |  12345   |     0      |
|  3   |  12345   |     0      |
|  4   |  12345   |     1      |
|__5___|__12345___|_____1______|

and this is php code for check data in test_table

<?PHP
    include("connect.php");
    $i = "0";

    $sql = "SELECT * FROM test_table WHERE pro_id = '12345' AND requests != '0' order by id asc limit $i,1";
    $query = mysql_query($sql);
    $result = mysql_fetch_array($query);
    if($result)
        echo "requests field";
    else
        echo "not requests field";
?>
  • 写回答

2条回答 默认 最新

  • douqi0090 2015-01-19 04:13
    关注

    Because $result is result-set it have 0 rows

    if(array)
        true;
       else
        false;
    

    it will always return true. because empty array is never equal FALSE;

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题