kjavia795 Posted June 21, 2008 Share Posted June 21, 2008 if ($row['status'] == 0) { $status = "Pending"; } if ($row['status'] == 1) { $status = "Completed"; } It shows everything is pending even if its status is 1 Quote Link to comment https://forums.phpfreaks.com/topic/111281-if/ Share on other sites More sharing options...
CMC Posted June 21, 2008 Share Posted June 21, 2008 Post more code and elaborate on the problem please. What's given is hardly helpful. Quote Link to comment https://forums.phpfreaks.com/topic/111281-if/#findComment-571211 Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 First of all, use elseif on the second one. Secondly, are you using == or =? That's a common problem. Quote Link to comment https://forums.phpfreaks.com/topic/111281-if/#findComment-571213 Share on other sites More sharing options...
.josh Posted June 22, 2008 Share Posted June 22, 2008 First of all, use elseif on the second one. Secondly, are you using == or =? That's a common problem. In his code it doesn't really matter either way. Either ==0 will work or it won't. Either ==1 will work or it won't. Both will be evaluated just the same. He could even use a switch statement here. Or if the value will only be 0 or 1, he could just do an if...else. As far as the problem goes, obviously $row['status'] is either 0 or false. More likely it is false. You need to go up and check where you're assigning that value. It could be any number of things. I'm going to assume the you're getting it from a sql query, based on $row being a common variable people like to use for assigning query results. -perhaps your mysql_connect failed -- use the right connection info? -perhaps your mysql_select_db failed -- use the right db name? -perhaps your mysql_query failed -- did you echo your query string to see if you're sending what you expect to the db? -perhaps you used the wrong column name -- perhaps you did not properly fetch the results In short: Post more code and elaborate on the problem please. What's given is hardly helpful. I think I'd start out by adding ...or trigger_error("SQL", E_USER_ERROR); after all your db function calls. Quote Link to comment https://forums.phpfreaks.com/topic/111281-if/#findComment-571241 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.