title: in one foreach call second foreach! codeigniter
body: <p>hier is the problem:
  in codeigniter in controller I have next code:</p>
  
  <pre><code>$query_not_voted = "SELECT * FROM photos WHERE p_id NOT IN (SELECT distinct p_id FROM p_votes where u_id = ".$this-&gt;session-&gt;userdata('u_id').") LIMIT ".$this-&gt;db-&gt;escape_str($segment_url).", ".$config['per_page'];
  $q = $this-&gt;db-&gt;query($query_not_voted);
  $data['myphotos'] = $q-&gt;result_array();
  
  foreach($data['myphotos'] as $key=&gt;$val)
  {
      $query_g = "SELECT * FROM users WHERE u_id = (SELECT u_id FROM p_votes WHERE p_id = ".$val['p_id'].")";
      $q_2 = $this-&gt;db-&gt;query($query_g);
      $data['allvotess'] = $q_2-&gt;result_array();
  
      $query_u = "SELECT * FROM users WHERE u_id = ".$val['u_id']." LIMIT 0, 5";
      $q_1 = $this-&gt;db-&gt;query($query_u);
      $data['author'] = $q_1-&gt;result_array();
  }
  </code></pre>
  
  <p>So now I have <code>$data['myphotos']</code> and this is can be outputted in view with next codes:</p>
  
  <pre><code>&lt;?php foreach ($myphotos as $keys =&gt; $myphoto){ ?&gt;
      &lt;div id="voteblock"&gt;
      &lt;div id="voteleft"&gt;
          &lt;a href="&lt;?php echo base_url().$myphoto['p_small']; ?&gt;" class="preview" title="&lt;?php echo base_url().$myphoto['p_title']; ?&gt;"&gt;&lt;img src="&lt;?php echo base_url().$myphoto['p_thumb']; ?&gt;" /&gt;&lt;/a&gt;
      &lt;/div&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>but how can I output <code>$data['allvotess']</code> in last foreach loop?
  I tried to do same, but didn't work out.</p>
  
  <p>Then I tried to push the results inside $data['myphotos'] and no good result!</p>
  
  <p>So What I'm Doing???</p>
  
  <p>Just need someone to help me with foreachloop insite foreachloop!!!
  For a week I just can't do, I can even pay for solution right now!!!</p>
  
  <p>I posted also at codeingiter forum, but they say it's easy hier is <a href="http://codeigniter.com/forums/viewthread/176599/" rel="nofollow">link</a></p>