I just came out of perl, and having a very hard time translating this line.
my @ref = ();
$username = $mem_info[2];
my @names = $username;
my $base_sql=q{SELECT username,status FROM members WHERE referral };
while (scalar(@names)) {
my $sql=$base_sql.($#names?'in ('.join(',',map('?',@names)).')':'=?');
my $sth=$dbh->prepare($sql);
my $rv=$sth->execute(@names);
my ($res,$status) = $sth->fetchall_arrayref();
@names=map($res->[$_][0],0..$#$res);
push @ref, join '|',@names if (scalar(@names));
last if $#ref == 2;
}
If you dont know perl, Ill tell you what I'm trying to do here.
In my database I have so that rows are like this
Username|Referral
apple|
scot|apple
pete|apple
tim|pete
billlyjoe|scot
penti|apple
So thats in my database, apple was referred by no one, scott, pete, penti was referred by apple. Tim was referred by pete. Im trying to get my results like this.
Level 1: apple
Level 2: scot|pete|penti
Level 3: tim|billyjoe
To get that in array I need it saved like this
$array = array('apple','scot|pete|penti','tim|billyjoe');
Is that a little better?