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
Share on other sites

However i need to add serial numbers to them.

WHAT DO YOU MEAN SERIAL NUMBER

IF you mean serial n database for showing add a field in the DB but if you want to ask the user for serial number before he sees the results this will be different case

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.