I'm currently working on displaying checked checkbox if its saved in database.
$stmt = $db->prepare('Select * from productsizes a, sizestops b WHERE
a.productinformationID = :prodID AND a.sizeID = b.sizestopsID ');
$stmt->bindParam(':prodID', $productID, PDO::PARAM_INT);
$stmt->execute();
$couunterer = $stmt->rowCount();
$y= 1;
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if($y != $couunterer)
{
echo $sizes5 = $row['sizetopsName']." ";
}
elseif($y == $couunterer)
{
echo $sizes5 = $row['sizetopsName']." ";
}
$y++;
}
This display my saved sizes for example XSMALL and LARGE
and this is my codes to display all checkbox from other table
$statement = $db->prepare("SELECT * FROM sizestops order by sizestopsID ASC");
$statement->execute();
while($rows2 = $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='" .$rows2['sizestopsID']. "'". $pre_checked.">".$rows2['sizetopsName']."
</label>";
}
This display all the sizes from
XSMALL, SMALL, MEDIUM, LARGE, XLARGE, XXLARGE, FREES SIZE
Now i want to display checked to checkbox XSMALL and LARGE only and the rest is not checked. How can i do that? Hopefully any one can help me with this thanks!
PHP and Javascript will do. Thanks
Aucun commentaire:
Enregistrer un commentaire