循环 MLM 矩阵递归 PHP
我在 Matrix 传销树或循环工作。我制作了递归函数并且运行良好。
它并没有像这样完全金字塔:
它只是在左手而不是在右手增加:
结果在这里
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";
} }
提前致谢
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:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论