Hi all i have found a bug in my db class when i use the recursion. I try to use the adjacency list model to develop a three menu but when i call the function in recursive way i loose data because the value returned from the fetch seem to be empty. I have db table like this: table catalog ID | Name_Category | Subcategory 1 node category 0 2 1_sub_category 1 3 2_sub_category 1 4 another_node 0 5 another_node 0 I have this db class code: http://phpfi.com/229087 And i create an instance of such class with this code. http://phpfi.com/229088 My problem is that i take only the fist main category, the subcategory of this node and later the function esc and doesn't print the other main category. I have try to use the native php mysql function and the code work then the problem i suppose is in my class. Procedural way with native functions unction buildThree($parent) { $sql = "SELECT id, name_category FROM category WHERE subcategory = {$parent}"; $rs = mysql_query($sql) or die(mysql_error()); if ($rs) { while (list($id, $nome) = mysql_fetch_array($rs)) { $sql2 = "SELECT id FROM category WHERE subcategory = {$id}"; $rs2 = mysql_query($sql2) or die(mysql_errno()); $total = mysql_num_rows($rs2); if ($total) { echo'<li> # '.$nome.' '."\n\r".'<ul>'."\n\r"; buildThree($id); echo"</ul>"."\n\r"."</li>"."\n\r"; } else { echo'<li> ?m=product&cat='.$id.' '.$nome.' </li>'."\n\r"; } } } } echo '<ul>'; buildThree(0); echo '</ul>'; echo '<ul>'; buildThree(0); echo '</ul>'; -- View this message in context: http://www.nabble.com/Debug-recursion-tf3632803.html#a10143940 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php