onedumbcoder Posted July 6, 2008 Share Posted July 6, 2008 i am trying to see if an element exist in result, if not print out br, but it is not doing that if(!$emptyList && $counterX > 0) { right(); $loop++; if($tracker) { if(isset($result)) { $List = mysql_fetch_array($result); } else { $emptyList = true; } } } else { echo "<br>"; } here result has only one element so after the first time it runs, it should go to emptylist = true, but that is not happening it is going to $list = mysql_fetch_array($result) can someone help me. ps the number of rows affected was 1, so i know for sure there is only one element. Link to comment https://forums.phpfreaks.com/topic/113482-if-statement-not-working/ Share on other sites More sharing options...
strayduck Posted July 6, 2008 Share Posted July 6, 2008 I think you need to specify a condition for isset($result), i.e. if (isset($result) == 1) or if (isset($result) != 0) Link to comment https://forums.phpfreaks.com/topic/113482-if-statement-not-working/#findComment-583098 Share on other sites More sharing options...
BloodyMind Posted July 6, 2008 Share Posted July 6, 2008 can u explain more ? and btw I see $result is always true u can say <?php if ($numrows > 0) { // do this }else { // do something else } ?> Link to comment https://forums.phpfreaks.com/topic/113482-if-statement-not-working/#findComment-583116 Share on other sites More sharing options...
strayduck Posted July 7, 2008 Share Posted July 7, 2008 I think you may have answered your own question! Yes, I think $result will always be true even if it returns no answers. Using the number of rows as a result is probably a better way of doing it, as you can use the code that you posted. Link to comment https://forums.phpfreaks.com/topic/113482-if-statement-not-working/#findComment-583422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.