MySQLi Num行检查行是否存在

时间:2017-05-21 06:54:23

标签: php mysqli

因此使用mysqli_num_rows检查ID是否存在。但现在它甚至没有加载。但它崩溃我的脚本,不知道我错过了什么,或者这是不是正确写入。

非常感谢任何帮助。有时候看到一些小错误需要新鲜的眼睛,我已经一遍又一遍地找到问题。

$get_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$affiliate_id"));

if (mysqli_num_rows($get_oc) > 0) 
{
    $set_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT commission from ap_oc where aff_id=$affiliate_id"));
    $comission = $set_oc['commission'];

    $get_tl_id = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT tl_id from ap_oc where aff_id=$affiliate_id"));
    $teamleaderid = $get_tl_id['tl_id'];

    $get_tl_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$teamleaderid"));

        if (mysqli_num_rows($get_tl_oc) > 0) {
            $set_tl_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT commission from ap_oc where aff_id=$teamleaderid"));
            $t2_comission = $set_tl_oc['commission'];
        } 
}

1 个答案:

答案 0 :(得分:0)

我完成了我需要处理的代码

   $get_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$affiliate_id"));
    $count_oc = $get_oc['id'];
    if($count_oc==''){$count_oc = 0;}
     if ($count_oc > 0) 
        {

对于将来可能有相同问题的任何人。

相关问题