PHP-MLM项目中的自动检查可用性位置


Auto Check Availability Position in PHP - MLM Project

我想让这个成为可能

如果我是用户,我的左和右像"L"answers"R"

我想php应该自动chk可能的空位置注册。像

1=L,2=R,3=LL,4=RL,5=LR,6=RR-

       user
       / '
  (1) L   R (2)
     /'   /'
(3) LL LR RL RR (6)
      (5) (4) 

如果发现"RL"位置为空(新用户应在"RL"下注册)

我的数据库有ID、用户名、Child_L、Child_R

我在下面写了这个代码

<?php
require_once 'config.php';
$username = "kishore";
$log=mysql_query("select * from users where username='".$username."'");
$row=mysql_fetch_array($log);
$child_left=$row['child_l'];
$child_left=$row['child_r'];
function chkchild($childuser){
    $log=mysql_query("select * from users where username='".$childuser."'");
    $row=mysql_fetch_array($log);
    $child_left=$row['child_l'];
    $child_left=$row['child_r'];
    if ($child_left = NULL) {
        echo"you can register under child_l";
    }elseif ($child_right = NULL){
        echo"you can register under child_r";
    }
}

if ($child_left = NULL) {
    echo"you can register under child_l";
}elseif ($child_right = NULL){
    echo"you can register under child_r";
}else 
    chkchild($child_left);

?>

这是我的数据库表

https://i.stack.imgur.com/eYvTH.jpg

这可能会帮助您

function chkchild(){
    while($t)
    {
        $qu=mysql_query("SELECT * FROM users WHERE child_L='' or child_R='';");
        $rows=mysql_fetch_row($qu);
        if($rows>0)
        {
            echo "No Positions are blank"
        }
        else
        {
            $rs=mysql_fetch_array($qu);
            //Here you can check the complete list of all blank positions
        }
    }
}