unable to display query results in a view codeigniter

前端 未结 2 1304
臣服心动
臣服心动 2021-01-22 16:47

I\'m trying to show the results from my database in a dynamic table, I\'m using codeigniter:

This is my model:

class Cliente_model extends CI_Model {

fu         


        
2条回答
  •  粉色の甜心
    2021-01-22 17:54

    Write this in your model function:

    $query = $this->db->get('cliente');
    $data = $query->result_array();
    return $data;
    

    And this in your controller:

    $data['client']= $this->cliente_model->obtenerDatos();
    $this->load->view('cliente_view',$data);
    

    Then add this to your view:

    
     
    

    etc...

    As you will see, $data['client'] is now holding your database info, and you can read it by looping through the associative array in your view. More info on query builder class here.

提交回复
热议问题