Display using codeigniter
code of display.php file located at application/views :-
display.php:-
<html>
<head>
</head>
<body>
<form>
<table border="1px">
<tr>
<th>Name</th>
<th>Salary</th>
<th>Delete</th>
<th>Edit</th>
</tr>
<?php foreach($data as $val) { ?>
<tr>
<td><?php echo $val->emp_name;?></td>
<td><?php echo $val->emp_salary;?></td>
<td><a href="<?php echo base_url()?>Cnt/delete_data?del=<?php echo $val->emp_id;?>" style="color:red">Delete</a></td>
<td><a href="<?php echo base_url()?>Cnt/edit_data?ed=<?php echo $val->emp_id?>">Edit</a></td>
</tr>
<?php } ?>
</table>
</form>
</body>
</html>
Controller code for display :-
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Cnt extends CI_Controller {
public function display_view(){
$data=$this->Model->get_data('emp1');
$this->load->view('display',['data'=>$data]);
}
}
Model code for Insertion :-
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Model extends CI_Model {
public function get_data($tbl)
{
$data=$this->db->get($tbl);
return $data->result();
}
}
Comments
Post a Comment