mardi 28 février 2017

how to display a php variable in input checkbox

i made a small user database with some checkboxes in a html input form. in there i have some basic infos about the users like value 1 and 2 (among others) and some checkboxes as well (here you see one). default is always 0, but when i click the checkbox its changes to 1.

<input type="text" placeholder="Value 1" value="<?php echo set_value('value1'); ?>" name="value1" size="6"/>
<input type="hidden" value="0" name="spec1"/><input type="checkbox" value="1" name="spec1"/>
<input type="text" placeholder="Value 2" value="<?php echo set_value('value2'); ?>" name="value2" size="6"/>

now i would like to have a form in which i can see all these informations later on and edit it if necessary. but the checkbox i cant display properly. it is always empty. so i had to change it to a textbox. so i can see whether that specific values are 0 or 1.

<input type="text" name="Value 1" value="<?php echo $value1; ?>">
<input type="text" name="spec1" value="<?php echo $spec1; ?>">
<input type="text" name="Value 2" value="<?php echo $value2; ?>">

is it possible somehow to show the values in a checkbox again, so i can change the type of the second line to "checkbox" again instead of "text"? means can i display a value 1 as a checked checkbox and 0 as an empty checkbox?




Aucun commentaire:

Enregistrer un commentaire