Here's my Delete button:
<td>
<a href="javascript:void(0);" onclick="delete(<?php echo $data->emp_id;?>);">
<button id="button_delete">Delete</button>
</a>
</td>
Here's my Javascript code:
<script type="text/javascript">
var url="<?php echo base_url();?>";
function delete(id)
{
var r=confirm("Do you want to delete this employee?");
if (r==true)
{
window.location = url+"index.php/admin_logins/employee4/"+id;
}
else
{
return false;
}
}
</script>
Here's my controller (admin_logins.php
) method -
function employee4($emp_id)
{
$this->employee_model->delete_employee($emp_id);
$this->index();
}
And here's my model(employee_model.php
) method -
public function delete_employee($emp_id)
{
$this->db->where('employee.emp_id',$emp_id);
return $this->db->delete('employee');
}
My table name is employee
and my database is MySQL.
Column Name Datatype
id int
emp_id varchar(15)
emp_name varchar(50)
emp_mobile_no varchar(15)
Whenever I click the Delete button, nothing happens. What am I doing wrong?