I am using the following query and I would like to change div colors based on the value of one of my queried items. In the code below I am trying to check the value of mgap_accept. if the value is 1 then the results will be output in a different div then if the value is not 1.
I did it with an IF?ELSE, bt Im unsure if there is a better way. here is my code:
$result_cat = "SELECT mgap_accept,mgap_ska_id FROM mgap_orders WHERE mgap_ska_id = '$id'";
$stmt = $pdo->prepare($result_cat);
$stmt->execute();
while($row_cat = $stmt->fetch(PDO::FETCH_ASSOC))
{
$id1=$row_cat['mgap_ska_id'];
$accept=$row_cat['mgap_accept'];
$growth=($total + $recovery);
if($accept == '1'){
?>
<div class="show">
<span class="namecustcoltype"><?php echo $id1; ?></span>
<span class="namecusttype"><?php echo $accept; ?></span>
<span class="growthcust">$<?php echo number_format($growth); ?></span>
</div>
<?php
}else{
?>
<div class="showop">
<span class="namecustcoltype"><?php echo $id1; ?></span>
<span class="namecusttype"><?php echo $accept; ?></span>
<span class="growthcust">$<?php echo number_format($growth); ?></span>
</div>
<?php
}
?>