How to delete a database table row when a button is clicked from my in CodeIgniter view
00:18 30 Jun 2014

I have a CodeIgniter page which displays a table of all the results. I want to have the option of being able to delete whichever row I want. I've added the function in model and controller and a delete icon is present in the view but I am not sure how to co-ordinate the same.

Function in Model:

function delete_row($job)
{
    $querystr = 'delete from jobs where job = \'' . $job . '\'';
    $query = $this->db->query($querystr);
    $arr = $query->result_array();
    $query->free_result();
    return ;
}

Function in Controller:

public function delete()
{
    $this->load->model('Job');
    $this->Job->delete_row($job);
    $this->load->view('my_view');
    return;
}

View:(my_view.php (snippet))

if ($key === 'job') {
    echo "";
}

The view has lot of functions in it but this above line is the one which enable the delete image to all the rows visible on the display.

php codeigniter model-view-controller sql-delete