3

I am working at Matrix MLM Tree or Cycle. I made recursion functions and It's working fine.

It's not making fully pyramid like so:

enter image description here

It's just increasing in Left Hand not at the Right hand:

Result Here

Left     ID     Right
  1
  2          
  3
  4          
  5
  6      
  7

Functions Here.

function abc($name, $id, $round) {
$query = "SELECT * from users where ref_id = $id";
$query = mysql_query($query);
while ($row = mysql_fetch_array($query)) {
    $data[] = $row;
}
if (count($data) < 2) {
    $pos = "l";
    if (!isset($data[1])) {
        if ($data[0]["position"] == "l") $pos = "r";
        else if ($data[0]["position"] == "r") $pos = "l";
    } else if (!isset($data[0])) {
        if ($data[1]["position"] == "l") $pos = "r";
        else if ($data[1]["position"] == "r") $pos = "l";
    }
    $inserted = mysql_query("INSERT into users VALUES('', '$name', $id, '$pos', $round)");
    if ($inserted) {
        echo "ID {$data[0][3]} . ' Reference Id ' . $id ";
        return true;
    }
} else if (count($data) == 2) {
    abc($name, $data[0]["id"], $round);

} else {
    echo "You already have left and right members in you cycle";
} }

Thanks in Advance

hakre
  • 193,403
  • 52
  • 435
  • 836
  • 1
    What is your question? And "Thanks in Advance" can be considered rude. – hakre Jul 17 '11 at 14:20
  • I want to make pyramid like http://runmlm.com/images/silver.gif – Essa Mamdani Jul 17 '11 at 19:26
  • Can you remove anything mysql from your question to decouple the database access from the problem? Or provide the design of the database tables in question. And additionally: What have you tried to solve your problem so far? Why do you think it does not work? – hakre Jul 17 '11 at 19:30

0 Answers0