dou4064 2014-08-27 03:39 采纳率: 100%
浏览 7

如果mysql在查询中没有返回任何内容,如何重定向或强制页面

working on a small project and having a small problem. i am querying mysql, i am able to get the array and everything works well but i am adding a additional condition if returns 0 or id does not match the query then redirect.

This is what i have so far.

$q = "SELECT TEST.*,
             EMPLOYEE.EMP_ID                     
        FROM TEST
        LEFT JOIN EMPLOYEE ON TEST.EMP_ID = EMPLOYEE.EMP_ID 
        WHERE ITEM_ID=".$db->qstr($item_id);

if(!$item_id = $db->execute($q)){
    force_page('system', 'Nothing found');
    exit;
} else {
    $view = $item_id->GetArray();
}

return $view;
}

so the above returns the array, query grabs $item_id from the url so it could be anything. i would like to check if that id exists if not then force the page as shown in the above. any suggestion on what i am doing wrong?

  • 写回答

4条回答 默认 最新

  • douche5961 2014-08-27 03:49
    关注

    I don't think there is any function like force_page(); in php You need to redirect like header("Location: Your_url");

    And If you have function force_page(); please post code of that.

    评论

报告相同问题?

悬赏问题

  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能