我正在尝试执行没有结果的 php 查询。我一直试图让它工作几个小时,并认为另一双眼睛会有所帮助。这是我的脚本:
if(!empty($cLvl))
{
$result = $conn->query("SELECT lvl" . $cLvl . "
FROM buyers WHERE buyer_id = $buyer");
$comRate = $result->fetch_assoc();
}
print_r($comRate); die;
$buyer
被发现:
$result = $conn->query("select source_id from inventory where sku = {$data[$n]['sku']}");
if($result) {$buyer = $result->fetch_assoc();}
并$cLvl
通过以下方式找到:
if($data[$n]['cost'] == 0 || $bookType3['book_type_3'] == "DMG")
{
$cLvl = null;
}
elseif($bookType['book_code'] == "IE" || $bookType['book_code'] == "AIE")
{
$cLvl = 3;
}
elseif($cId['condition_id'] == 1 || $cId['condition_id'] == 2 || $cId['condition_id'] == 3 || $cId['condition_id'] == 4 || $follett['class_code'] == "D" || strpos($follett['notes'],"(T)") == true)
{
$cLvl = 2;
}
elseif($cId['condition_id'] == 5)
{
$cLvl = 1;
}
在我的测试$buyer = 263
和$cLvl = 3
. 但是,当我尝试查找时$comRate
,它什么也不返回。如果我在信息中硬编码我会得到一个结果,但这将运行大约 250 条记录,我不能对每条记录都进行硬编码。
我哪里错了?