Nuv Posted May 26, 2011 Share Posted May 26, 2011 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']); } } Quote Link to comment https://forums.phpfreaks.com/topic/237507-adding-serial-number-to-my-function/ Share on other sites More sharing options...
hemo-ali Posted May 26, 2011 Share Posted May 26, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/237507-adding-serial-number-to-my-function/#findComment-1220482 Share on other sites More sharing options...
Nuv Posted May 26, 2011 Author Share Posted May 26, 2011 My code displays the children of the root. I just want to display serial numbers like if the code displays 10 children. I want to number them from 1 - 10. Those serial number. Quote Link to comment https://forums.phpfreaks.com/topic/237507-adding-serial-number-to-my-function/#findComment-1220489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.