title: PHP syntax help on if statement
body: <p>I'm trying to determine the right syntax from what I'm trying to do with MySQL. I'm basically saying that if a value in a certain column of a row of a table is equal to some session variables, I want to echo out info.</p>
  
  <p>I have a table with <code>subject</code>, <code>description</code> and <code>user</code>. <code>User</code> is set by taking the current user's first name and last name and inserting it into the table under <code>user</code>. This is done by the following code:</p>
  
  <pre><code>$sql="INSERT INTO tbl_name (subject, description, user)
  VALUES
  ('$_POST[subject]','$_POST[description]','$_SESSION[firstname] $_SESSION[lastname]')";
  </code></pre>
  
  <p>Then once I'm calling this data back out, I want to basically allow the user to delete content that they submitted themselves. The first step for me is to be able to display it in the table. I believe this is just syntax error, but I've confused myself now with how things are set up:</p>
  
  <pre><code>$sql = "SELECT * FROM tbl_name ORDER BY subject, description 
    LIMIT {$startpoint},{$limit}";
  $result = $mysqli-&gt;query($sql);
  $num_rows = mysqli_num_rows($result);
  
  if($num_rows&gt;0){
  $field_num = $mysqli-&gt;field_count;
  echo "&lt;h1&gt;HERE ARE SOME EXAMPLES:&lt;/h1&gt;";
  echo "&lt;table border='0'&gt;&lt;tr&gt;";
  
  for($i=0; $i&lt;$fields_num; $i++)
      {
          $field = mysql_fetch_field($result);
          echo "&lt;td&gt;{$field-&gt;subject}&lt;/td&gt;";
          echo "&lt;td&gt;{$field-&gt;description}&lt;/td&gt;";
          echo "&lt;td&gt;{$field-&gt;user}&lt;/td&gt;";
          if('$field-&gt;user' == '$_SESSION[firstname] $_SESSION[lastname]'){
            echo '&lt;td&gt;You can delete this&lt;/td&gt;';
          }
      }
  </code></pre>
  
  <p>I figured the <code>$field-&gt;user</code> would equal <code>$_SESSION[firstname] $_SESSION[lastname]</code> because that's how it was initially submitted to the table (without the '.' for concatenation).</p>
  
  <p>Any help would be appreciated. Thanks!</p>
  
  <h2>EDIT</h2>
  
  <p>Here's the result of my table output code. The results are actually being display with $cell instead of from within the for loop I believe. I've added the if statement in after the but it doesn't seem to recognize <code>echo "&lt;td&gt;".$field-&gt;user."&lt;/td&gt;";</code> which makes me think that that is where the problem lies. What I would like to do is be able to add the if statement in a  immediately after `echo {$field->user}"; to keep the code clean. I think I've confused myself thoroughly:</p>
  
  <pre><code>if($num_rows&gt;0){
  $field_num = $mysqli-&gt;field_count;
  echo "&lt;h1&gt;HERE ARE SOME JOBS:&lt;/h1&gt;";
  echo "&lt;table border='0'&gt;&lt;tr&gt;";
  
  for($i=0; $i&lt;$fields_num; $i++)
  {
      $field = mysql_fetch_field($result);
      echo "&lt;td&gt;{$field-&gt;subject}&lt;/td&gt;";
      echo "&lt;td&gt;{$field-&gt;description}&lt;/td&gt;";
      echo "&lt;td&gt;{$field-&gt;user}&lt;/td&gt;";
  
      if($field-&gt;user == $_SESSION[firstname]." ".$_SESSION[lastname]){
      echo '&lt;td&gt;You can delete this&lt;/td&gt;';
      }
      else{
      echo "&lt;td&gt;".$field-&gt;user."&lt;/td&gt;";
      echo "&lt;td&gt;".$_SESSION[firstname]." ".$_SESSION[lastname]."&lt;/td&gt;";
      }
  }
  
  echo "&lt;/tr&gt;\n";
  while($row = mysqli_fetch_row($result))
  {
      echo"&lt;tr&gt;";
  
      foreach($row as $cell)
          echo "&lt;td&gt;$cell&lt;/td&gt;";
          echo "&lt;/tr&gt;\n";
  }
  mysqli_free_result($result);
  }
  else{
  echo 'There are no jobs!';
  }
  </code></pre>