title: Select value from foreach result
body: <p>Hi is there a way to get the value from each foreach result.
  For Example I have a table named tblsamp.</p>
  
  <pre><code>id |   data   |
  1  |    d1    |
  2  |    d2    |
  3  |    d3    |
  </code></pre>
  
  <p>then put some query: </p>
  
  <pre><code>$query = $this-&gt;db-&gt;query("SELECT * FROM tblsamp");
  foreach ($query-&gt;result() as $row){
  echo $row-&gt;data .'&lt;br&gt;';   
  } 
  </code></pre>
  
  <p>Result is:</p>
  
  <pre><code>d1
  d2
  d3
  </code></pre>
  
  <p>Now what I want is I want to get the value of the first result and compare the value from another table, and so on...</p>
  
  <p>For Example:</p>
  
  <pre><code>if('d1' == '(value from another table)'{
   \\do something here
  } else if ('d2' == '(value from another table)'{
   \\and so on.....
  }
  </code></pre>
  
  <p>how can I do this guys? TIA!.</p>