Jump to content

Adding serial number to my function


Nuv

Recommended Posts

I made a function which displays the left and right children of the root. However i need to add serial numbers to them. Due to Recursive functions i'm not quite able to to do so . Can someone please help me?

function side_display($root)
  {
      $sql = "SELECT lchild,rchild FROM tree WHERE parent='".$root."'";
      $sqlexec = mysql_query($sql);
      $array = mysql_fetch_array($sqlexec);
      if(!empty($array['lchild']) && $array['lchild'] != '0')
      {
          echo "<tr>";

          echo "<td>".($array['lchild'])."</td>";
          $get = "SELECT * FROM member WHERE member_id='".$array['lchild']."'";
          $execget = mysql_query($get);
          $getarray = mysql_fetch_array($execget);
          echo "<td>".$getarray['fname']." ".$getarray['lname']."</td>"; 
          echo "<td>".$getarray['id_sponsor']."</td>" ;
          echo "<td>Left</td>"; 
          echo "<td>".$getarray['doj']."</td>" ;
          echo "</tr>";
          side_display($array['lchild']);
      }
      if(!empty($array['rchild']) && $array['rchild'] != '0')
      {
         echo "<tr>";

          echo "<td>".($array['rchild'])."</td>";
          $get = "SELECT * FROM member WHERE member_id='".$array['rchild']."'";
          $execget = mysql_query($get);
          $getarray = mysql_fetch_array($execget);
          echo "<td>".$getarray['fname']." ".$getarray['lname']."</td>"; 
          echo "<td>".$getarray['id_sponsor']."</td>" ;
          echo "<td>Right</td>"; 
          echo "<td>".$getarray['doj']."</td>" ;
          echo "</tr>";
          
          side_display($array['rchild']);
      }
   
  } 

 

Link to comment
https://forums.phpfreaks.com/topic/237507-adding-serial-number-to-my-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.