61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
class Tournaments extends CI_Controller {
|
|
|
|
|
|
|
|
public function update($tournament_id = null) {
|
|
// Check if $tournament_id is provided
|
|
if ($tournament_id === null) {
|
|
// Handle the case where $tournament_id is not provided
|
|
// You may redirect to an error page or perform other actions
|
|
}
|
|
|
|
$this->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
|
|
));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
?>
|