I want the value that is depended on the checked of the user
1st checkbox = 1, 2nd checkbox = .5, 3rd checkbox .5 that will be inserted/updated to the players column name "player_attitude" if the user check 1st box and 3rd the value of the user will be 1.5 in column "player_attitude"
My table name is players with the columns
player_id,player_fname,player_address,player_attitude
Since the player is already registered i want to add/update player attitude of the user
View
<form action="<?php echo base_url('Evaluations/update') ?>" method="POST">
<?php foreach($evaluationlist as $players): ?>
<tbody>
<tr>
<td> <?php echo $players->player_lname?> , <?php echo $players->player_fname?>
</td>
<td><center>
<input type="checkbox" name="checkbox1" value="1">
</center></td>
<td><center>
<input type="checkbox" name="checkbox2" value=".5">
</center></td>
<td><center>
<input type="checkbox" name="checkbox3" value=".5">
</center></td>
<td></td>
<td>
<a href="<?php echo base_url('Players/editview/'.$players->player_id) ?>"><span class="b"><span class="glyphicon glyphicon-check">Manage</span></span></a>
</td>
</tr>
</tbody>
<?php endforeach; ?>
Controller
public function update($player_id){
$this->load->model('User_model');
$this->User_model->checkIfLoggedIn();
$this->load->view('incf/header');
$this->load->view('evaluationf/ev_tools');
$checkbox1 = $this->input->post('checkbox1');
$checkbox2 = $this->input->post('checkbox2');
$checkbox3 = $this->input->post('checkbox3');
$player_attitude = $checkbox1+$checkbox2+$checkbox3;
//print_r($player_attitude); exit();
$this->load->model('Evaluation_model');
if($this->Evaluation_model->editview($player_id,$player_attitude)){
$this->session->set_flashdata('message', [
'status' => 'success',
'message' => ' <span class="glyphicon glyphicon-ok-circle"> Account Successfully Updated!</span>'
]);
redirect(base_url('Players'));
}else{
$this->session->set_flashdata('message', [
'status' => 'danger',
'message' => ' <span class="glyphicon glyphicon-remove-circle"> Please try again.</span>'
]);
redirect(base_url('Players'));
}
}
Model
public function editview($player_id,$player_attitude){
$data = [
'player_attitude' =>$player_attitude
];
$this->db->where('player_id',$player_id);
return $this->db->update('players',$data);
}
Aucun commentaire:
Enregistrer un commentaire