Welcome Guest, Not a member yet? Register   Sign In
navigation problem
#1

[eluser]dimis[/eluser]
I have done a function to find the category and all subcategories names and urls (category table) but it works only for the first category.
What is wrong?
Code:
function mymenunameCats($id,$name='Categories')
    {
        //if (!empty($name))
        $myname=$name;
       // else
       // $myname="";
      
        $sql="SELECT `categories`.`id` as id,coalesce(categories.cat_id,0) as cat_id, `name`, `short_id` FROM (`categories`)
        JOIN `categories_lan` ON `categories`.`id` = `categories_lan`.`cat_id` WHERE categories.`id`=$id and  categories_lan.lan_code=(select  lan_code from lan where lan_copy='1' )
        ORDER BY `name` asc";
        $query =  $this->db->query($sql);
        foreach ($query->result() as $row)
        {
            $namee=$row->name;
            $pid=$row->cat_id;
            $id=$row->id;
            // return ($name);
        }
        if (!empty($myname))
        $thisname= $myname." | ".anchor("manager/cats/subproducts/".$id,$namee) ." | ";
        else
        $thisname= anchor("manager/cats/subproducts/".$id,$namee);
        if ($pid>0 )

        $this->mymenunameCats($pid,$thisname );
        else
        return  $thisname ;

    }
#2

[eluser]GSV Sleeper Service[/eluser]
Code:
foreach ($query->result() as $row)
        {
            $namee=$row->name;
            $pid=$row->cat_id;
            $id=$row->id;
            // return ($name);
        }
you are over-writing the $namee, $pid and $id vars on each iteration of this loop.




Theme © iAndrew 2016 - Forum software by © MyBB