Hi all,
I have an if statement here that works well except when i try to put it inside of the code you see starting at line 7. What you see on line 1 is only the code I want to insert. The code you see at line 5 is inside of a while loop if that helps.

if (is_null($avatar)) { echo "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { echo "<img src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}  



if ($ulevel == '1' && !$inactive) {
          $display .= "<tr id=\"item_" . $row['id'] . "\">"
          ." <td><img src=\"avatars/thumbs/$avatar\"class=\"thumb\" alt=\"Avatar\" /><br/>" . $uname . "</td>"
          ." <td>" . $email . "<br/><br/><br/><a href=\"user_profile.php?view_profile=$uname\">See agents profile here</a></td>"
          ." <td>" . $time . "</td>"
          ." </tr>\n";

I have tried the following:

if ($ulevel == '1' && !$inactive) {
          $display .= "<tr id=\"item_" . $row['id'] . "\">"
          ." <td>"if (is_null($avatar)) { echo "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { echo "<img src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}"<br/>" . $uname . "</td>"
          ." <td>" . $email . "<br/><br/><br/><a href=\"user_profile.php?view_profile=$uname\">See agents profile here</a></td>"
          ." <td>" . $time . "</td>"
          ." </tr>\n";

Thanks in advance for any help,

PhaedrusGhost

one thing is for sure, the condition didn't satisy the if statements. try echoing those variables to see their value, ie $avatar, $ulevel and $inactive

Here is the entire code (which I should have included from the beginning:

function displayUsers()
  {
      global $db, $pager, $session;
	  
	  $pager = new Paginator();
	  $counter = countEntries('users');
	  $pager->items_total = $counter;
	  $pager->default_ipp = $session->set['user_perpage'];
	  $pager->paginate();
	  
	  if ($counter == 0) {
		$pager->limit = "";
	  }
      
      $sql = "SELECT * FROM users ORDER BY userlevel DESC, username " . $pager->limit;
      $result = $db->query($sql);
      
      $display = '';
      while ($row = $db->fetch($result)) {
          $uname = $row['username'];
          $ulevel = $row['userlevel'];
          $email = $row['email'];
          $time = date("M-d-Y H:i", $row['timestamp']);
		  $avatar = $row['avatar'];
		  $inactive = $row['token'] != 0;
		  
//THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY
		  if (is_null($avatar)) { echo "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { echo "<img
			  src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}  
//END-THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY
		  
          if ($ulevel == '1' && !$inactive) {
          $display .= "<tr id=\"item_" . $row['id'] . "\">"
		  ." <td><img src=\"avatars/thumbs/$avatar\"class=\"thumb\" alt=\"Avatar\" /><br/>" . $uname . "</td>"
		  ." <td>" . $email . "<br/><br/><br/><a href=\"user_profile.php?view_profile=$uname\">See agents profile here</a></td>"
		  ." <td>" . $time . "</td>"
		  ." </tr>\n";
          
          $display .= "<tr id=\"editUserRow_" . $row['id'] . "\" style=\"display:none\">
      <td>&nbsp;</td>
      
      </tr>\n";
      }
	  }
      
      if (!$result) {
          return false;
      } else {
          return $display;
      }
  }
?>

This is what I use to display it:

//THIS DISPLAY EVERYTHING I NEED WITH THE EXCEPTION OF THE $AVATAR IF STATEMENT
<?php echo displayUsers();?>

Hope this makes better sense...

Thanks again..

Here you have echo displayUsers(); meance whatever will be return from that function will be echoed.
Your whole function is concating $display and returning it.
But in if statement you have directly make echo.

//THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY
		  if (is_null($avatar)) { echo "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { echo "<img
			  src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}  
//END-THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY

It should be something like this,

//THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY
		  if (is_null($avatar)) { $display .=  "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { $display .=  "<img
			  src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}  
//END-THIS IF STATEMENT DISPLAYS WHAT I NEED PERFECTLY

So, might be this is bug,
concate avtar image coding with some variable and then return it.

Let me know if it works.

Hi vibhadevit and thanks for you reply..

Since I need the if statement inside of lower if statement the $display .= is already defined, does it need to be defined again like you've written?

//THIS IF STATEMENT WAS USED TO SEE IF I COULD GET RESULTS ONLY BUT THIS STATEMENT NEEDS TO BE... ---SEE BELOW
		  if (is_null($avatar)) { echo "<img src=\"avatars/thumbs/default.jpg\"class=\"thumb\" alt=\"Avatar\" />"; } else { echo "<img
			  src=\"avatars/thumbs/$avatar\"class=\"thumb\"alt=\"Avatar\" />";}  
//END-THIS IF STATEMENT WAS USED TO SEE IF I COULD GET RESULTS ONLY BUT THIS STATEMENT NEEDS TO BE... ---SEE BELOW
		  
          if ($ulevel == '1' && !$inactive) {
          $display .= "<tr id=\"item_" . $row['id'] . "\">"
// ...HERE -- THIS IS WHERE I NEED THIS IF STATEMENT...
		  ." <td><img src=\"avatars/thumbs/$avatar\"class=\"thumb\" alt=\"Avatar\" /><br/>" . $uname . "</td>"
// END-...HERE -- THIS IS WHERE I NEED THIS IF STATEMENT...
		  ." <td>" . $email . "<br/><br/><br/><a href=\"user_profile.php?view_profile=$uname\">See agents profile here</a></td>"
		  ." <td>" . $time . "</td>"
		  ." </tr>\n";
          
          $display .= "<tr id=\"editUserRow_" . $row['id'] . "\" style=\"display:none\">
      <td>&nbsp;</td>
      
      </tr>\n";
      }
}

Again, I really appreciate the help on this.

One more thing on that...please make note of the notes in green on this script.

I think you want to display default.jpg if user have not avtar image. right?
Use below code, here directly included with ternary operator of if else .
Now no need to write extra if condition.

$display .= "<tr id=\"item_" . $row['id'] . "\">"
		  ." <td><img src=\"avatars/thumbs/".((is_null($avatar))?('default.jpg'):($avatar))."\"class=\"thumb\" alt=\"Avatar\" /><br/>" . $uname . "</td>"
		  ." <td>" . $email . "<br/><br/><br/><a href=\"user_profile.php?view_profile=$uname\">See agents profile here</a></td>"
		  ." <td>" . $time . "</td>"
		  ." </tr>\n";

This worked perfectly! Much appreciated. Would you mind helping me understand what the "?" represents and how the ":" is working here? Would love some clarification.

Totally appreciated...

this is same like if-else, but very useful in coding.

(condition)?'go to here if condition is true':'go to here if condition is false'

See below example.

$a=5;
$signOfA = ($a>0)?'positive':'negative';
echo $a.' is '.$signOfA;

$a=-5;
$signOfA = ($a>0)?'positive':'negative';
echo $a.' is '.$signOfA;

Hope you get it. ;)