load->model('Tournament_model'); // If the form is submitted, update the tournament if ($this->input->post()) { $postData = $this->input->post(); var_dump($postData); $this->Tournament_model->update_tournament($tournament_id, $postData); // Debugging: Check if the update query is executed echo $this->db->last_query(); $this->session->set_flashdata('success', 'Tournament updated successfully.'); redirect('manage_tournament'); // Redirect to the tournament list or details page } // Load the tournament details for the form $data['tournament'] = $this->Tournament_model->get_tournament($tournament_id); $this->load->view('update_tournament', $data); } public function delete() { $tournamentId = $this->input->post('tournament_id'); // Add your model function to delete the tournament record by ID $this->load->model('Tournament_model'); $this->Tournament_model->delete_tournament($tournamentId); // You can return a response if needed //$this->session->set_flashdata('success', 'Tournament deleted successfully.'); //echo json_encode(['message' => 'Tournament deleted successfully']); echo json_encode(array( "statusCode"=>200 )); } } ?>