[英]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.