using codeigniter query i am unable to get appropriate results i need to get results of a table this way
$catid=$_POST['category'];
$new_id = select catid from categories_table where catid='$catid' and parent='$catid';
so it will add also include results of other cats have $cadid as parent
Select * from articles_table where catid = '$new_id';
i am trying in codeigniter like this
$p=$this->input->post('category');
$this->db->select('catid');
$this->db->where('parent',$p);
$this->db->where('catid',$p);
$query = $this->db->get('categories_table');
if($query->num_rows()>0)
{
foreach($query->result() as $row)
$new_id[]=$row->catid;
}
$this->db->where('catid',$new_id);
$this->db->where('status',1);
$this->db->order_by('time_added', 'desc');
$res = $this->db->get('articles_table');
$query_res= $res->result();
it gives the error Message: Trying to get property of non-object
cats table
catid -- parent -- name
1 -- 0 -- first cat
2 -- 1 -- cat child of first
Article table
id -- catid - content
1 -- 2 -- first article
2 -- 1 -- second article
if i query where cat id = 1 it should return results from catid 2 too as 2 is child of one