我尝试从2个独立的表中查看数据,但这个错误就出来了:查看数据
"Notice: Trying to get property of non-object in D:\xampp\htdocs\testsubject\User\inventory.php on line 18"
这是我的PHP代码:
$sql = "SELECT storage_details.itemCODE,storage_details.pckgeID,storage_details.cndition,storage_details.duration,pckge_info.price,storage_details.status
FROM storage_details
INNER JOIN pckge_info
ON storage_details.pckgeID=pckge_info.pckgeID";
$result = $link->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "itemcode: " . $row["itemCODE"]. " - packageid: " . $row["pckgeID"]. "condition: " . $row["cndition"]. "duration: " . $row["duration"]. " status: " . $row["price"]. " " . $row["status"]."<br>";
}
} else {
echo "0 results";
}
mysql_free_result($result);
哪一个是第18行?我只能猜测它是'if($ result-> num_rows> 0){'或'$ result = $ link-> query($ sql);',无论如何,请向我们展示大图(前代码) – MorKadosh
是的..它的if($ result-> num_rows> 0) –
我不能让你的完整代码,因为它不会让我发布,因为我的帖子有太多code.the上部分只需要数据库连接和会话 –