I'm using codeigniter and have a problem with my edit form in checkbox. The checkbox have 2 values 1 and 0, if checked then the value is 1 and if unchecked then the value is 0.
here is my controller:
function updatepost($id=0){
$data = $_POST;
$this->db->where('id_post',$id);
$outp = $this->db->update('post',$data);
}
And here is my view
sport <input type="checkbox" name="sport" value="1" <?php if($data['sport'] == '1'){echo 'checked';}?> />
tekno <input type="checkbox" name="tekno" value="1" <?php if($data['tekno'] == '1'){echo 'checked';}?>/>
game <input type="checkbox" name="game" value="1" <?php if($data['game'] == '1'){echo 'checked';}?>/>
if i unchecked the checkbox, value should be '0';
My question is how to get value if the checkbox is uncheked?
Many thanks for the answer..
Aucun commentaire:
Enregistrer un commentaire