lundi 23 novembre 2015

How to auto check checkboxes value from database PHP

Im having a trouble to auto check the checkboxes value i want to auto check the checkbox if its in database for example

$statement = $db->prepare("SELECT * FROM sizestops order by sizestopsID ASC");
$statement->execute();

while($rows = $statement->fetch(PDO::FETCH_ASSOC)) {

echo "
<label style=' display:inline-block;
        width:150px;
        height:50px;
        margin:-1px 4px 0 0;
        vertical-align:middle;'>
      <input type='checkbox' name='sizes[]' class='checkbox' id='sizesprod' onchange='checksize()'  value='" .$rows['sizestopsID']. "'>" . $rows['sizetopsName']  ."</label>

      ";

    }

Normally it displays SMALL, MEDIUM, LARGE, XLARGE, XXLARGE

But in my database the only saved are

SMALL and MEDIUM only..

In my edit form i want to display that my SMALL and MEDIUM are checked in my checkbox group

How can i do that?

Thanks hope you can help me.




Aucun commentaire:

Enregistrer un commentaire