Jump to content

if statement not working


onedumbcoder

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.