I am new in PHP programming. I'm doing 1 assignment to display treestructure of categories with it's subcategories. I get all categories through query but result of query of saubcategories give only one record, i have 3 subcategories. Why this is happen? My query gives proper result in Mysql Query Browser but on my site I get only one subcategory. Please do reply.
This is my function to get result: function getHello($params) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $userId = (int) $user->get('id'); /* return categories*/ $query='Select id,title from jos_sections s'; $db->setQuery( $query ); $section = $db->loadObjectList(); /*return subcategories of particular sections*/ $qid='Select id from jos_sections s'; $db->setQuery($qid); $data=$db->loadObjectList(); $i = 0; $lists = array(); //while($row = mysql_fetch_array($query)) foreach ($section As $lSection) { $lists[$i]->text = htmlspecialchars( $lSection->title ); $query1 = 'Select s.id,s.title,c.id, c.title From joomladb.jos_sections s Inner Join joomladb.jos_categories c On s.id=c.id Where s.id= '.$lSection->id ; ?> <br> <?php $db->setQuery( $query1 ); $cat = $db->loadObjectList(); $j = 0; foreach ($cat as $lCat) { $lists1[$j]->text = htmlspecialchars( $lCat->title );} echo $lists1[$j]->text; $j++; } $i++; //} return $lists.$lists1 ; }