Welcome Guest, Not a member yet? Register   Sign In
Recursive Use Of function
#1

[eluser]Unknown[/eluser]
function get_category($Id)
{
global $category_arr;
if($Id != “”)
{
$this->db->select(’*’);
$this->db->from($this->categories_table);

$this->db->where(‘iCategoryId = ‘.$Id);

$this->db->order_by(‘vCategory’, ‘’);

$query = $this->db->get();

$cat = $query->row();

if($cat->iParentId != ‘’)
{
$category_arr[]=$cat->iCategoryId;
$this-> get_category($cat->iParentId);
}else
{
return false;
}
}
}

I am using this function and it gives error

Internet Explorer cannot display the webpage

What you can try: in ie

And

Content Encoding Error

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
* Please contact the website owners to inform them of this problem.in ff.

when i use get_category function repeatedly. And also if i declare a global variable global $category_arr; i am unable to get its value. Please check it out and reply as soon.
#2

[eluser]therealmaloy[/eluser]
matrukrupa

post your category structure with dummy data inserts, as well as the model. { lazy to create my own Smile }

i'll try to run this on my machine.

i like solving recursion Smile




Theme © iAndrew 2016 - Forum software by © MyBB