doutui2883 2019-03-30 09:38 采纳率: 100%
浏览 44
已采纳

从codeIgniter函数回显结果需要jquery

when echoing an array from a mysql query, console sends me an error that it needs jquery.

my problem originally was how to output the one query result from an array. I found a solution where using $arrayName[index][index] should do it but when I tried it the browser console shows an POST http://localhost:8080/logInCon/validate_LogIn 500 (Internal Server Error)

this is the query function

Model:
public function logInCheck($uname, $psswrd)
    {
        $log = $this->db->query("SELECT COUNT(*) AS 'verified' FROM `users` WHERE `uname` = '$uname' AND `pwd` = '$psswrd' LIMIT 1;");
        return $log->result();
    }

this is results Controller:

public function validate_LogIn()
    {
        $uname = $this->input->post('uname');
        $pass = $this->input->post('pass');
        $this->load->model("accsModel");
        $data = $this->accsModel->logInCheck($uname, $pass);

        echo $data[0]['verified'];
    }

I want to get that one value inside $data

  • 写回答

2条回答 默认 最新

  • 普通网友 2019-03-30 09:42
    关注

    You can echo simply this way.

    A better way to use active record

    Model function / query

    public function logInCheck($uname, $psswrd)
        {
            $this->db->select('COUNT(*) AS verified');
            $this->db->where('uname', $uname);
            $this->db->where('pwd', $psswrd);
            $this->db->limit(1);
            return $this->db->get('users')->row_array();
        }
    

    Result / used function

    public function validate_LogIn()
        {
            $uname = $this->input->post('uname');
            $pass = $this->input->post('pass');
            $this->load->model("accsModel");
            $data = $this->accsModel->logInCheck($uname, $pass);
    
            echo $data['verified'];
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料