I have the requirement where i m using checkbox, when user checked the checkbox then value of chekbox saved as 1 and when checkbox is uncheked then value store as 0 , this code works //add
<input type='hidden' name='status' value='0'/>
<input type='checkbox' name='status' value='1' <?php echo (isset($_POST['status']))?'checked':'';?>/>
and if data is inserted in db ,if data is 1 then it should show checked and when data is 0 it should show unchecked this also works
//edit
<input type="checkbox" name="status" value="1" <?php echo ($row['status'] == 1) ? 'checked="checked"' : ''; ?>/>
till now its working but when user tries edit this chekbox then also previous value get stored in db not new one
Aucun commentaire:
Enregistrer un commentaire