Welcome Guest, Not a member yet? Register   Sign In
Category DB call convert to CI - Model/Controller help
#6

[eluser]gtech[/eluser]
well result_array will just return somthing like

array('0'=>array('col1'=>'data','col2'=>'data'),'1'=>array(....etc)...etc);

so when passed in to the views you will have the variables $0 $1 ect defined this is not what you want.

instead pass the result_array inside an array.
Code:
$viewdata = array();
$viewdata['categories'] = $this->mdl_home->get_categories();
$this->load->view('view_file', $viewdata);

then the view will have the $categories array available to you in the view.
Code:
<ul>
&lt;?php foreach($categories as $key => $value):?&gt;
  <li>&lt;?php echo $key.":".$value;?&gt;</li>
&lt;?php endforeach;?&gt;
</ul>

if you did
&lt;?php print_r($categories); ?&gt; in the view would would see how the array is built up.


Messages In This Thread
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 01:10 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 02:25 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 02:30 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 03:03 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 06:21 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 06:30 PM
Category DB call convert to CI - Model/Controller help - by El Forum - 05-25-2008, 09:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB