我打算成为可能的是
如果我是用户,我的左,右是“L”和“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);
?>
这是我的数据库表
答案 0 :(得分:0)
可能会帮助你
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
}
}
}