CodeIgniter Forums
Function requires table data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Function requires table data (/showthread.php?tid=57925)



Function requires table data - El Forum - 04-26-2013

[eluser]Unknown[/eluser]
Hello,

How can I pass a functions data into a view if it requires the table data in the views foreach loop.

e.g view_index.php

Code:
foreach ($posts as $post) {
if (has_subscribed($post->id)) {
echo "has subscribed";
}
}

Now obviously I can't place that function in my view?
So how do I pass that data from my controller to my view?


Function requires table data - El Forum - 04-26-2013

[eluser]Sudz[/eluser]
Hi,

While loading views in your function add second parameter as an array.

Code:
$data['posts'] = '' // here your table data will be there
$this->load->view(' your view file',$data);