Jump to content

fetch array


hoachen

Recommended Posts

Hi guys, I need some help with you. I try to echo the data from the database but i have to check one specific column(status). If that column contain 'pending' or 'cancelled' then this rows will not be echo else echo all the data. Here is what i have try but it echo everything outwhile ($mod = $objIncident->fetch()) { $showstat = $data->getStatus(); if ($showstat != "pending" || $showstat != "cancelled" ) { echo $data->getName(); echo $data->getCity(); echo $data->getComplaints(); } else { echo ''; }

Link to comment
Share on other sites

it is a simple mistake, look at your conditionif($showstat != "pending" || $showstat != "cancelled")think about it for a second...the answer to that condition will ALWAYS be true so that is why it always echos the data.Change || to && and you should be fine.

Link to comment
Share on other sites

I see, thanks for you sharpe spot. I got it works now. THanks

it is a simple mistake, look at your conditionif($showstat != "pending" || $showstat != "cancelled")think about it for a second...the answer to that condition will ALWAYS be true so that is why it always echos the data.Change || to && and you should be fine.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...