i'm making a product crud in codeigniter but i have this problem with my code:
A PHP Error was encountered Severity: Notice
Message: Undefined variable: ver
Filename: views/productos_view.php
Line Number: 51
Backtrace:
File: C:\wamp64\www\catalogo\application\views\productos_view.php Line: 51 Function: _error_handler
File: C:\wamp64\www\catalogo\application\controllers\Welcome.php Line: 23 Function: view
File: C:\wamp64\www\catalogo\index.php Line: 315 Function: require_onc
Welcome.php
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('productos_view');
}
}
Controller function
//controlador por defecto
public function index(){
//array asociativo con la llamada al metodo
//del modelo
$productos["ver"]=$this->productos_model->ver();
//cargo la vista y le paso los datos
$this->load->view("productos_view",$productos);
}
Model
public function ver(){
// //Hacemos una consulta
$consulta=$this->db->query("SELECT * FROM catalogo;");
// Devolvemos el resultado de la consulta
return $consulta->result();
}