I am new to codeigniter, I have managed to get insert working into the database and I have done the code to delete from the database however when clicking on the job to delete it, it just refreshes and the job is still in the database.
My Controller
public function deleteclientform(){
$this->load->helper('form');
$this->load->model("clientmodel");
$data['clients']=$this->clientmodel->getallclients();
$data['title']="Delete Job";
$this->load->view("deleteclientform",$data);
}
public function delete(){
$films=$this->input->post('clients');
$this->load->model("clientmodel");
foreach($clients as $jobno)
{
$this->clientmodel->deleteclient($jobno);
}
redirect('/nav/home', 'refresh');
}
My Model
function deleteclient($jobno)
{
$this->db->where('jobno', $jobno);
$result=$this->db->delete('client');
return $result;
}
My View
echo form_open('client/delete');
foreach($clients as $client)
{
echo "<p>";
echo form_label($client->job, 'client'.$client->jobno);
$data = array('name' => 'clients[]', 'jobno'=>'client'.$client->jobno, 'value' => $client->jobno);
echo form_checkbox($data);
echo "</p>";
}
echo form_submit("delete_btn","Delete these Jobs");
echo form_close();
$clientscome from in yourcontroller?clients/delete?foreach($clients as $jobno)should beforeach($films as $jobno)