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. Quote Link to comment 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) Quote Link to comment 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 } ?> Quote Link to comment 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. Quote Link to comment 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.