class index_model extends CI_Model {
public function get_data()
{
$query = $this->db->query('SELECT * FROM sgrn_tblrecipe_addnew ORDER BY POPULARITY DESC LIMIT 4');
$result=$query->result();
foreach($result as $row)
{
$variable=$row->RECIPE_ID;
$this->myOtherFunction($variable);
}
return $result;
}
function myOtherFunction($variable)
{
$query = $this->db->query('SELECT * FROM sgrn_tblrcp_user_like WHERE RECIPE_ID="'.$variable.'"');
$result =$query->num_rows();
echo $result;
return $result;
}
}
Hi I try this code developed by me for accessing different table data in different variable,but i have one problem that it doesn't give the result of second query.
Actually i use call by function technique by passing variable as parameter...if any other method is available then suggest me...
I have to use multiple select queries in MODEL for fetching data from database by different table but after getting first query result by these ID i have to use in second query WHERE clause that gives different result from different table....
and these two results access on VIEW as different data to view