vendredi 23 juillet 2021

How to display a checked checkbox in a PHP update form? postgres sql

I have to show a checked check box (like this one), but currently when extracting the value from the database (it shows this).

Is there a way to show the checked check box when extracting the known value from the database (PgAdmin)(All code is either HTML,CSS or PHP)

Code:

    Topings: <br><br>
 <label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Vanilla") echo "checked" ?> value="<?php echo $row['toping'];  echo "checked" ?>"><span class="checkmark"></span><span class="checkbox-txt"> Vanilla</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Chocolate") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark"></span><span class="checkbox-txt" >Chocolate</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Caramel") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark"></span><span class="checkbox-txt" >Caramel</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Strawberry") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark"></span><span class="checkbox-txt" >Strawberry</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="M&M's") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark"></span><span class="checkbox-txt" >M&M's</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Oreo") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark"></span><span class="checkbox-txt" >Oreo</span><br/></br></label>
<label class="checkbox-container">
<input type="checkbox" name="toping" <?php if(isset($_POST['toping']) && $_POST['toping']=="Meringue") echo "checked" ?>value="<?php echo $row['toping']; ?>"><span class="checkmark "></span><span class="checkbox-txt" >Meringue</span><br/></label>



Aucun commentaire:

Enregistrer un commentaire