vendredi 20 octobre 2017

PHP echo single checkbox

Trying to get a checkbox result to echo but running into problems.

Have tried the following code. If the value is 1 (which is what is inserted into the db), then it should be checked when the page loads. If it is null or empty then it should obviously not be checked. With this code, it's always unchecked.

<?php
if  ($row['notadmin'] == '1')
{
echo " <input type='checkbox' name='notadmin' id='notadmin' value='checked'>";
}
else
{
echo "<input type='checkbox' name='notadmin' id='notadmin' >";
}    

?>




Aucun commentaire:

Enregistrer un commentaire