[eluser]Unknown[/eluser]
m returning array from model..and want to loop it in the view...here is my code...it works perfect in controller..and plz help me in passing same value to the VIEW
Code:
public function gets()
{
$query="select name from cat";
$query1=$this->db->query($query);
foreach($query1->result_array() as $row)
{
$q="select * from post where cat=?";
$q1=$this->db->query($q,$row['name']);
$max[]=array(
'a'=>$row['name'],
'b'=> $q1->num_rows()
);
}
return $max;
}
controller
Code:
public function login()
{
print_r($tested=$this->Go->gets());
$data['g']=$tested;
//this code works 5n
foreach($tested as $test)
{
echo $test['a'];
echo $test['b'];
}
$this->load->view('login',$data);
}
view:
Code:
foreach($g as $h);
{
//doesnt loop all the values only last value
echo $h['a'];
echo $h['b'];
}
thanks