doulu1945 2016-04-12 06:08
浏览 29
已采纳

使用PHP无法从数据库中获取正确的字段

I want to get rows in the database in which:

"l_area" is the table column

"in consignment" is the table

and the restriction "l_area" is equal to the stored value in "area" variable.

My code is shown below. It is only outputting all the selected items even if l_area is not equal to area.

    function get_all()
    {
        $area = $this->session->userdata('area'); 
        $this->db->select('l_area','d_area','description','dom','tom'); // the select statement
        $this->db->where('l_area' == $area);
        $q = $this->db->get('consignment'); // the table    
    }
  • 写回答

1条回答 默认 最新

  • doushi1964 2016-04-12 06:12
    关注

    Try this

    public function get_all()
    {
        $area = $this->session->userdata('area'); 
        $this->db->select('*'); // the select statement
        $this->db->where('l_area',$area);
        $query = $this->db->get('consignment'); // the table   
        $result = $query->result_array();
    
        print_r($result);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部