recursive function to get all the child categories

后端 未结 7 717
时光取名叫无心
时光取名叫无心 2020-12-03 03:54

Here is what I\'m trying to do: - i need a function that when passed as an argument an ID (for a category of things) will provide all the subcategories and the sub-sub categ

相关标签:
7条回答
  • 2020-12-03 04:37
    <?php    
    require('db/dbconnect.php');   
    
    $user_id='triD-100';   
     $sql="select * from ajent_joining where sponser_id='".$user_id."'";   
     $qR=mysql_query($sql);   
     while($rowD=mysql_fetch_assoc($qR)){    
      echo $childId=$rowD["user_id"]; 
        echo "<br/>";  
      categoryChild($childId);    
       }   
    
      function categoryChild($childId) {   
    
        $s = "select user_id from ajent_joining where sponser_id='".$childId."'";
        $r = mysql_query($s);
        if(mysql_num_rows($r) > 0) {
    
           while($row = mysql_fetch_array($r)) {
    
              echo $childId=$row["user_id"];
              echo "<br/>";   
               categoryChild($childId);
        }
    }
    
    }
    
    
    ?>
    
    0 讨论(0)
提交回复
热议问题