[英]MySQLi Num Rows to check if row exist
因此使用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'];
}
}
我完成了此代码所需的工作
$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)
{
对于将来可能会有相同问题的任何人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.