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 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的
  • ¥15 我看了您的文章,遇到了个问题。