vendredi 8 février 2019

Php Boolean attribute from phpmyadmin for an if statement

i have this code to get data from the database

$inf = array();
   $que = "SELECT * FROM `business_attributes` WHERE Business_ID = ".$_GET['id'];
    $res = mysqli_query($connect, $que);
    while ($row = mysqli_fetch_assoc($res)) {
        $inf[$row['Business_ID']] = array("Single" => $row['Single'], "Family" => $row['Family']
        , "Wireless" => $row['Wireless'], "Parking_Lot" => $row['Parking_Lot']
        , "Price_Range" => $row['Price_Range'], "Fast_Service" => $row['Fast_Service']
        , "Pets" => $row['Pets'], "Smoking" => $row['Smoking']);
    }

   foreach ($inf as $z)
{
    $family=$z['Family'];
    $single=$z['Single'];
    $pets=$z['Pets'];
    $wireless=$z['Wireless'];
    $fastS=$z['Fast_Service'];
    $parking=$z['Parking_Lot'];
    $price=$z['Price_Range'];
    $smoking=$z['Smoking'];

}

now when i use echo then the name of the variable it shows me its content and i can use it in my if statement. However,whenever i try to check if it has value or a condition for the attributes with the data type binary "tinyint(1)" in the database then it doesnt work.

for example:

 <?php  if($single==1)   //if the value is 1 or TRUE i tried both
                       //i tried them as a string as well and it didnt work
           // the value in the database is shown to me as 1 in phpmyadmin
                            {   ?>

                            <div class="col-md-4">
                                <label class="custom-checkbox">
                   <span class="ti-check-box"></span>
                   <span class="custom-control-description">Special</span>
                 </label> </div>

                 <?php } ?>

or simply

echo $single;

nothing appears. How to fix that ?

Aucun commentaire:

Enregistrer un commentaire