Welcome Guest, Not a member yet? Register   Sign In
Can echo out of controller but don't understand how pass to view?
#4

[eluser]Edemilson Lima[/eluser]
You must set a variable with your result and them pass it to your view:

Code:
$data['results']=$query->result();
$this->load->view('myview',$data);

Then you must place the foreach() into your view file, using the alternative PHP syntax:

Code:
<table>
&lt;?php foreach($results as $row): ?&gt;
<tr>
    <td>&lt;?=$row['field1']?&gt;</td>
    <td>&lt;?=$row['field2']?&gt;</td>
</tr>
&lt;?php endforeach; ?&gt;
</table>

By this way, you also keep your presentation logic separated from your controller.


Messages In This Thread
Can echo out of controller but don't understand how pass to view? - by El Forum - 01-18-2008, 12:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB