Welcome Guest, Not a member yet? Register   Sign In
[solved] Making a parentlist of id
#7

Solution found


PHP Code:
function getCategoriesByParentId($fid) {
     
   $category_data = array();

     
   $category_query $this->db->query("SELECT * FROM forum WHERE fid = '" . (int)$fid "'");

     
   foreach ($category_query->result() as $category) {
     
       
            $category_data
[] = array(
     
           'pid' => $category->pid,
     
       );

     
       $children $this->getCategoriesByParentId($category->pid);

     
       if ($children) {
     
           $category_data array_merge($children$category_data);
     
                 
        
}

     
   return $category_data;
    } 


And

PHP Code:
      $all_categories $this->getCategoriesByParentId(36);

        $arr = array();

        foreach ($all_categories as $category) {
            $arr[] = $category['pid'];
        }

        echo implode(','$arr); 
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Making a parentlist of id - by InsiteFX - 12-05-2016, 04:01 AM
RE: Making a parentlist of id - by wolfgang1983 - 12-05-2016, 04:16 AM
RE: Making a parentlist of id - by Wouter60 - 12-05-2016, 08:53 AM
RE: Making a parentlist of id - by wolfgang1983 - 12-05-2016, 08:53 PM
RE: Making a parentlist of id - by Paradinight - 12-05-2016, 09:27 PM
RE: Making a parentlist of id - by wolfgang1983 - 12-05-2016, 10:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB