我有这样的SQL查询:
$sql = "SELECT op.reference_no, op.eight_percent, op.ten_percent,
op.date, op.claim, op.orders_history_id,
oh.one_product_price, oh.quantity
FROM order_promotion op
LEFT JOIN orders_history oh
ON oh.id = op.orders_history_id
WHERE oh.customer_id = $member_id
UNION ALL SELECT type, receiveable, null AS a, null AS b, null AS c,
null AS d, null AS e, null AS f
FROM infimoney_transfer
我可以在这里回显表标签内的数据<td>".$objek->receiveable."</td>
它从表中回显记录。
但是当我试图检查记录是否存在时:
$saldo = $mysqli->query($sql);
if(!$saldo){ printf("Errormessage: %s\n", $mysqli->error); die(); }
if ($saldo->num_rows > 0) {
while($objek = $saldo->fetch_object()) {
$thq = $objek->receiveable; // line 50
var_dump($objek->receiveable); // line 51
echo $objek->receiveable; // line 52
if ($thq)
{
$i++;
echo "<tr>
<td>".$objek->type."</td>
<td>".$objek->receiveable."</td> // line 59.
<td>".$i."</td>
<td></td>
<td></td>
<td></td>
<td>Cinta</td>
</tr>";
}
它出现以下错误:第50,51,55行中的Undefined property: stdClass::$receiveable
。在第59行中,它回显记录而没有错误。
有什么问题?
答案 0 :(得分:0)
试试这个:
while($objek = $saldo->fetch_object()) {
if (isset($objek->receiveable))
{
$thq = $objek->receiveable; // line 50
var_dump($objek->receiveable); // line 51
echo $objek->receiveable; // line 52
$i++;
echo "<tr>
<td>".$objek->type."</td>
<td>".$objek->receiveable."</td> // line 59.
<td>".$i."</td>
<td></td>
<td></td>
<td></td>
<td>Cinta</td>
</tr>";
}