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 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测