mercredi 19 avril 2017

how to use enum from mysql to if statement php

so i have here my query update which i use an enum.. if status is 1 the result wont be displayed but if status is 0 it will be displayed..

function updatestatuspost($poid,$uid)
{
    $sql = "UPDATE post SET status = '1' WHERE post_id='$poid' AND member_id = '$uid'";
    $query = $this->dbh->prepare($sql);
    $result = ($query->execute() ? true : false);
    return $result;
}

this query is fine but the problem is the displaying part..

foreach ($res as $value)
{
    if('1' == $value['status'] )
    {
        echo display.....
    }
    else{
        echo dont display..
    }
}

what happens is when the if is == 1 nothing is being display but when if is != 1 all data is being displayed.. is there any way to call the value from my db which is 1/0 and compare it to the status. cause what i wanted to do is when status is 1 data will be displayed and if 0 is not... 1/0 is an enum set from my db...

Aucun commentaire:

Enregistrer un commentaire