implementing mlm plan with php
<p>I have to develope a tree structure for the following MLM plan using PHP---</p>

<p>root is :  admin(id=0)
level 1: id 1  , id 2 ..... upto id 10 joins and place under admin (maximum number of child per node=10)</p>

<p>level 2: now id 11, id 12, id 13 and  so on ....joins</p>

<pre><code>    here  id 11 is placed below 1  , id 12 is placed below id 2, ....id 20 is placed below id 10
again id 21 is placed below 1, id 22 is placed below 2 .... and so on ...

(as this level1 has 10 nodes so total 10*10=100 members will be there in level2; i.e 11,12,....110)
</code></pre>

<p>level 3: when id 111 comes , it is placed below 11 
                 112 comes , it is placed below 21   (as 21 is next to 11 then 31 ,41...)
                 113 comes ,it is placed below 31   and so on</p>

<p><strong>An overall view of the tree is :</strong>
level 0:                    0
level 1:     1   2  3  4  5  6  7  8  9  10
level 2:  (11,21,31,41,51,61,71,81,91,101)(12,22,23,24,25,26,27,28,29,30).....(20,30,40,50,60,70,80,90,100,110)
level 3:  111,211,311,411,511,...112,212,312.....  </p>

<pre><code>This process continues upto level 6

My problem is to determine the parent(below which to be placed) from the id of a newly registered member .  
**I have tried :**   
 `if(id%10!=0)
 {
     parent=id%10;
 }
else
{
parent=10;
}
 `
</code></pre>

<p>but actually this works only with the level2 nodes  not others....</p>

<p>I am still working on it..... and I shall be grateful for your help. </p>
