Ok, I can see what you mean.

Here is a updated sample table format I use: (Ignore the autoid after this code, I will remove it as it is not pertinent to any of this)
autoid bigint unsigned primary key auto_increment, MemberId bigint unsigned, referrer_id bigint unsigned, rank1 ENUM("0","1","2") DEFAULT "0" comment "1 when member acheives th +is rank; 2 when temporarily does not qualify", rank1_traditional BIGINT UNSIGNED DEFAULT "0", ranked1 BIGINT UNSIGNED COMMENT "Member this person is coded to", rank2 ENUM("0","1","2") DEFAULT "0" comment "1 when member acheives th +is rank; 2 when temporarily does not qualify", rank2_traditional BIGINT UNSIGNED DEFAULT "0", ranked2 BIGINT UNSIGNED COMMENT "Member this person is coded to", #...Other non related fields such as name and registration info...
Now each member has a unique MemberId, when they refer someone that person gets the referrers MemberId in the referrer_id field so for instance: Start with You for example
 Level   MemberName   MemberId   referrer_id   rank1 
0 You 427890 48 1


and you refer John, John would have a record like this:
 Level   MemberName   MemberId   referrer_id   rank1 
1 John 427891 427890 0


Then let's say John referrs Jane:(added only the rank1_traditional to show who this person is in the array of)
 Level   MemberName   MemberId   referrer_id   rank1   rank1_traditional 
2 Jane 427892 427891 0 427890


(added this next one), let me take it a little farther... Jane refers several...
 Level   MemberName   MemberId   referrer_id   rank1   rank1_traditional 
3 Tom 427893 427892 0 427890
3 Dick 427894 427892 0 427890
3 Harry 427895 427892 1 427890


4th Level small example:
 Level   MemberName   MemberId   referrer_id   rank1   rank1_traditional 
4 Bob 427896 427895 0 427895


So you would have 4 levels of referrers, John, Jane, Tom, Dick, Harry and Bob. John is whom you referred, but we would not have any of them if you did not refer John.

Also note that in the example Harry is a rank1 ranked member so Bob does not carry the MemberId from 'you', rather he carries Harry's MemberId since he is ranked as rank1. - This is why when I am climbing down the member tree, I check if he person I am looking at is ranked and if so, I do not go down their referral tree, because they will be looked at on their own in the very first loop because they are ranked...

We are like an advanced affiliate program, it is very close to MLM, but it is free to join and members get free retail websites several marketing sites and so forth and so on...

We compensate up to 60 cents on every dollar to our club members for referring the people they do. Once they achieve a certain predetermined number of personal referrals and those personal referrals achieve rank1 then the member is given rank2. There are actually 3 different rankings, but I am only showing the last two, as those are the only ones that are going to give bonuses on overrides.
Anyhow, So let me show you what I mean. When the club members have 30 people in the first 4 levels and at least 3 personally referred members whom have made a purchase at least in this calandar month or last calander month then they qualify to be at rank1. that is why there is a enum of 2 in the field because if somehow they are unqualified for a month or two, they can get qualified again.
These ranks were meant to reward them for all they do and give them something to work towards. So those that are rank1 then everyone they referred and that thoses people referred and that those ones did and so forth all the way to infinity referred will be coded to them in the traditional coded infinity which is rank1_traditional. That is to infinity until it reaches someone else that is ranked as rank1 because they will get everyone in their array below them coded to them.

I don't track levels, I only do that is I climb down for informational purposes, it is really irrelevent to this part. I have another program I wrote that does the formuals to see who qualifies for what and send them notices. This one just goes through and does the coding of them. It pays them once per month, at the beginning of every month for the last month. so that also is a different program.

I hope that gives you everything you asked for, please let me know if I missed something that would help.

Thank you very much Rich

In reply to Re^4: Recursive programming question by ukndoit
in thread Recursive programming question by ukndoit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.