dongsuyou6938 2014-01-21 19:03
浏览 112

为什么mysql_fetch_array()不起作用?

I'm trying to build a in/out marker in PHP, but having problems when trying to choose a date limit. I have a very long SQL but have simplified it to this:

if (($office_name == "All") && ($group_name == "All") 
   && ($fullname == "All") && ($from_date == '') && ($to_date == '')) 
{
    $query2 = "select * from ".$db_prefix."info";
    $result2 = mysql_query($query2);

} 
elseif (($office_name == "All") && ($group_name == "All") 
       && ($fullname == "All") && ($from_date != '') && ($to_date != '')) 
{
    $query2 = "select employees.empfullname, info.fullname, info.`inout`, 
                      info.timestamp
              from employees, info 
              where info.timestamp >= '".$from_date."' 
                    and info.timestamp <= '".$to_date."' 
                    and employees.empfullname = info.fullname
                    and employees.tstamp IS NOT NULL";
    $result2 = mysql_query($query2);
}

if($result2 === FALSE) {
    die(mysql_error()); 
}

while($row = mysql_fetch_array($result2)){
//some more code
}

Basically if the 'from' and 'to' fields are filled then it searches in timestamp and returns values that are greater or equal to 'from' and less or equal to 'to'. I think the problem is there because when I don't put anything (first case) it shows just fine.

No matter what I put inside the while loop nothing is return. There are no errors reported and connection to DB is well. I have no idea what could be wrong with this, or how to fix it since i don't know what is wrong and no errors show.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧