php - Edit and delete issues in codeigniter -
i tried of steps here, until now, edit , delete functions not work correctly. can please me it?
first, have these lines in client controller:
public function edit_job { $this->validaterole('client'); $this->load->model('job_model'); $id = $this->uri->segment(3); $data['my_preference'] = $this->array_to_select( $this->job_model->get_all_categories(), 'id','name'); $data['job'] = $this->job_model->get_job($id); $this->load->view('client/edit_job', $data); } public function delete_job() { $this->validaterole('client'); $this->load->model('job_model'); $id = $this->uri->segment(3); $this->job_model->delete_job($id); //echo '<script language="javascript">alert("post deleted.");</script>'; redirect('client/manage_jobs?message=job post deleted'); } }
then, have these lines in job_model
function edit_job() { $data = array( 'title' => $this->input->post('title'), 'category_id' => $this->input->post('category_id'), 'start_date' => date("m-d-y", strtotime($this->input->post('start_date'))), 'description' => $this->input->post('description'), ); $this->db->where('id', $this->input->post('id')); $this->db->update('job', $data); } function delete_job($id) { $this->db->where('id', $id); $this->db->delete('job', $data); }
currently, add job works quite (although have problem start date), edit , delete not work well. whenever press edit in view page, show page similar new add_job page (so whenever type , fill in form, added new job, not revision of particular job) (i've been trying echo original values first before editing can done, never worked. in terms of delete job, show redirect message, whenever check jobs available, supposedly deleted job still available.
i have been stuck here quite time now. please me..
i think asp_tags disable in php settings. change code following:
<?php echo $this->uri->segment(3, 0); ?>
instead of
<?= $this->uri->segment(3, 0); ?>
and delete, don't need pass second parameter in delete function. following:
$this->db->delete('job');
instead of
$this->db->delete('job', $data);
Comments
Post a Comment