A PHP Error was encountered Severity: Notice
Message: Undefined property: Showdata::$Data_Model
Filename: controllers/Showdata.php
Line Number: 23
Backtrace:
File: C:\xampp\htdocs\CURD\application\controllers\Showdata.php Line: 23 Function: _error_handler
File: C:\xampp\htdocs\CURD\index.php Line: 315 Function: require_once
An uncaught Exception was encountered Type: Error
Message: Call to a member function Get_Data() on null
Filename: C:\xampp\htdocs\CURD\application\controllers\Showdata.php
Line Number: 23
Backtrace:
File: C:\xampp\htdocs\CURD\index.php Line: 315 Function: require_once
controller
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Showdata extends CI_Controller {
function __construct() {
parent::__construct();
#$this->load->helper('url');
$this->load->model('data_model');
}
public function index(){
$data['user_list'] = $this->Data_Model->Get_Data();
$this->load->view('data_view', $data);
}
}
?>
view
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>User Details</title>
</head>
<body>
<h2> Simple Data Display </h2>
<table width="600" border="1" cellpadding="5">
<tr>
<th scope="col">Id</th>
<th scope="col">User Name</th>
<th scope="col">Email</th>
<th scope="col">Mobile</th>
<th scope="col">Address</th>
</tr>
<?php foreach ($user_list as $u_key){ ?>
<tr>
<td><?php echo $u_key->id; ?></td>
<td><?php echo $u_key->name; ?></td>
<td><?php echo $u_key->email; ?></td>
<td><?php echo $u_key->address; ?></td>
<td><?php echo $u_key->mobile; ?></td>
</tr>
<?php }?>
</table>
</body>
</html>