0

Below is the code that not returning anything but echoing values; it should return 'something' on false of if($return['status']=='Active')

function product($ids)
{
    $return = mysql_fetch_array(mysql_query("select * from tbl_product where id = $ids"));
    if($return['category_id'])
        $recursive_return = recursive($return['category_id']);  

    $recursive_return;  
}

function recursive($category_id)
{
    $return = mysql_fetch_array(mysql_query("select * from tbl_main_category where id = $category_id"));
    if($return['status']=='Active')
        recursive($return['parentId']);
    else
        $rr = 'something';

    return $rr; 
}

$return = product(1049);
echo $return;

Edited by Pravesh_1

2
Contributors
2
Replies
19
Views
2 Years
Discussion Span
Last Post by Pravesh_1
0

before answering your question, what is your purpose for using the PHP recursive function or a function that calls itself?

Just give me one reason why.

Edited by veedeoo: more info added

0

In line 12; I am using a table with parentid within itself and status; that means I have unlimited category and subcategory; suppose if a category's status is inactive the it's all sub-category will be inactive. So, I want to check inactive status of its parent-category.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.