<?php
$a=array('Cricket','Reading','Travelling','Swimming','Badminton');$hb=explode(" ",$row['hobby']);
?>
Hobbies:<input type="checkbox" name="chk[]" value="Cricket"<?php if(in_array('Cricket',$hb)){echo 'checked="checked"'; }?> />Cricket
<input type="checkbox" name="chk[]" value="Reading" <?php if(in_array('Reading',$hb)) { echo 'checked="checked"'; }?> />Reading
<input type="checkbox" name="chk[]" value="Travelling" <?php if(in_array('Travelling',$hb)) { echo 'checked="checked"'; }?> />Travelling
<input type="checkbox" name="chk[]" value="Swimming" <?php if(in_array('Swimming',$hb)) { echo 'checked="checked"'; }?> />Swimming
<input type="checkbox" name="chk[]" value="Badminton" <?php if(in_array('Badminton',$hb)) { echo 'checked="checked"'; }?> />Badminton
mercredi 1 juillet 2015
I want to get checkbox already checked when we retrieve data from database in edit form
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire