so my table is like this....
comments | status
asd | 1
qwe | 0
nmb | 1
qwer | 0
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 for display all the data on my database which limits to 5
function getAllPost(){
$query = "SELECT * FROM post JOIN members ON members.member_id=post.member_id ORDER BY post_id DESC LIMIT 5";
$result = $this->dbh->prepare($query);
$result->execute();
$data = array();
while($row = $result->fetch(PDO::FETCH_ASSOC)){
$data[] = $row;
}
return $data;
}
this query is fine but the problem is the displaying part..
<?php
$res=$db->getAllPost();
foreach ($res as $value)
{
if('1' == $value['status'] )
{
?>
<?php
} else{
?>
<strong class="font-1-2" style="margin-left:15px;"><?php echo '<a class="text-muted" href="profileview?member_id='.$value['member_id'].'">'.$value['firstname'].' '.$value['lastname'].'</a>';?></strong>
}
}
what happens is when the if is == 1 all of my data is not being displayed but when if is != 1 all data is being displayed even if other data is = 0.. is there any way to call the value from my db which is 1/0 and compare it using if statement. cause what i wanted to do is when status is if the data has status of 1 it will not be displayed and will be displayed and if is 0..