我在Matrix MLM Tree或Cycle工作。我做了递归函数,它工作正常。
它并没有像这样完全金字塔:
左手只是增加而不是右手:
结果
Left ID Right
1
2
3
4
5
6
7
此处的功能。
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";
} }
先谢谢