MLM表当我点击父链接第一次显示完美的这里孩子但第二次点击不显示完美的结果 [英] MLM table when i click on parent link first time show the perfect here child but second time click not show perfect result

查看:35
本文介绍了MLM表当我点击父链接第一次显示完美的这里孩子但第二次点击不显示完美的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$con = mysql_connect("localhost","root","");
if($con)
{
    echo " Localhost Connected<br/>";
}
$db = mysql_select_db("mlm_db",$con);
if($db)
{
    echo"<br/>Database Connected<br/>";
}
function rowSpanCount($no, $sid)
{
    //echo $sid;
    $result = mysql_query("select * from mlm_tbl where Sub_id =".$sid);
    $result1 = mysql_query("select * from mlm_tbl where Sub_id =".$sid);
    $cnt = count(mysql_fetch_assoc($result));
//  echo "<br/>".$cnt;
    //echo "no=".$no."\nsid=".$sid;
    if($cnt == 1)
    {
        $no ++;
        //echo "\n CNT=".$cnt."\n";
        return 1;
    }
    else
    {
        $no = 0;
    }
    while($assarray = mysql_fetch_assoc($result1))
    {
        $id = $assarray['id'];
        $nm = $assarray['Name'];
        //echo $nm. " - ";
    //  echo "\n..".$id;
        if($cnt == 1)
        {
            $no ++;
        }
        //echo $no;
        //echo "U =".$no."=".$nm."=U";
        $no = $no + rowSpanCount($no, $id);
        //echo "N =".$no."=N<br/>";
    }
    //echo "==noo=".$no;
 return $no;
}
//echo rowSpanCount(0,4);
function createTable($sid)
{
    $result = mysql_query("select * from mlm_tbl where Sub_id =".$sid);
    //$i=1;
    while($assarray = mysql_fetch_assoc($result))
    {
        $id = $assarray['id'];
        $nm = $assarray['Name'];
        $s_id = $assarray['Sub_id'];

        //echo $id."==".$nm."==".$sid."<br/>";
        $i=rowSpanCount(0,$id);
        //echo "iii".$i;
        echo"<td rowspan='".$i."'>";
        /*
        if($id == 1)
        {
            $i=8;
            echo "<td rowspan='".$i."'>";
        }
        else if($id == 2 or $id == 3 )
        {
            $i=4;
            echo "<td rowspan='".$i."'>";
        }
        else if($id==4 or $id==5 or $id==6 or $id==7)
        {
            $i=2;
            echo"<td rowspan='".$i."'>";
        }
        else
        {
            $i=1;
            echo"<td rowspan='".$i."'>";
        }*/
        echo "<a href='http://localhost/mlm/demo_table.php?id=".$id."&sid=".$sid."'>".$nm."</a>";
        echo"</td>";

        createTable($id);
        echo"</tr>";
    }
}

echo "<table border='1'><tr>";
createTable($_GET['id']);
echo "</table>";
    $cnt = 0;
    function checkid($id)
    {
        $result = mysql_query("select * from mlm_tbl where Sub_id =".$_GET['sid']);
    }
    $result = mysql_query("select * from mlm_tbl where Sub_id =".$_GET['sid']);
    //$resultt = mysql_query("select * from mlm_tbl where id =".$_GET['sid']);
    //$i=1;
    while($assarray = mysql_fetch_assoc($result))
    {
        $id = $assarray['id'];
        $nm = $assarray['Name'];
        $s_id = $assarray['Sub_id'];

        $cnt = count(mysql_fetch_assoc($result));
        /*if($cnt!=2)
        {
            if($_GET['sid']==2 && $_GET['id']==4)
            {
                $id=1;
                $s_id=2;
            }
            if($_GET['sid']==3 && $_GET['id']==6)
            {
                $id=1;
                $s_id=3;
            }
            if($_GET['sid']==6 && $_GET['id']==3)
            {
                $id=2;
                $s_id=1;
            }
            if($_GET['sid']==2 && $_GET['id']==1 )
            {
                $id=0;
                $s_id=0;
            }
            if($_GET['sid']==1 && $_GET['id']==3)
            {
                $id=0;
                $s_id=1;
            }
        }*/
        if($_GET['id']!=0)
        {
            echo"<a href='http://localhost/mlm/demo_table.php?id=".$s_id."&sid=".$id."'>Parent</a>";
        }
    }

推荐答案

con = mysql_connect( localhost root );
if(
con = mysql_connect("localhost","root",""); if(


con)
{
echo Localhost Connected< br />;
}
con) { echo " Localhost Connected<br/>"; }


db = mysql_select_db( mlm_db


这篇关于MLM表当我点击父链接第一次显示完美的这里孩子但第二次点击不显示完美的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆