douzhang3822 2013-04-18 12:03
浏览 23

如何在mysql表中获取userid的下线

Currently i'm using php and mysql to fetch downlines of a particular userid. Is there any way i can just use mysql to do that. My code is......

function downlineSearch($mid, $s) 
{
    global $nums; global $str;
    $q = $cn->query("SELECT userid, CONCAT(lastname,' ',firstname,' ',middlename) AS name FROM clientsdata WHERE (recid LIKE '%$s%' OR lastname LIKE '%$s%' OR firstname LIKE '%$s%' OR middlename LIKE '%$s%') AND sponsor = $mid");
    while($r = $q->fetch_array(MYSQL_ASSOC)) 
    {
        $nums += 1;
        $str .= "<tr><td valign='middle'>NRN".$r['userid']."CCN</td><td valign='middle'>".$r['name']."</td></tr>";
        downlineSearch($r['userid'], $s);
    }
}

$str = '';
downlineSearch($mid, 'janet');
echo '<table id="tblSearch" width="100%">';
echo "<tr><td colspan='4' align='center' style='padding-top:10px;'><h3> $nums records found for [ <span style='color:red'>".$_POST['s']."</span> ]</h3></td></tr>";
echo $str;
echo '</table>';`

PLEASE ANY HELP WOULD BE HIGHLY APPRECIATED. THANKS

  • 写回答

1条回答 默认 最新

  • 普通网友 2013-04-18 15:23
    关注

    My guess it that you need to set the value of $cn, probably something like that:

        $cn = new mysqli;
    

    Does that help?

    What is the error message you are getting?

    Do you know in which line the error happens?

    Do you have ability to debug line-by-line and view variables? If not, add several "echo" statements, to view in browser what's going on. Or, use error_log(), to display info in PHP error log, if you have access to it.

    (I'm sorry about asking for clarification in an "answer", but the system does not let me add comments to other people's question - yet. As soon as you add some clarification, I will revise this "answer" to be actual answer to your question.)

    评论

报告相同问题?

悬赏问题

  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。