我嘗試從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上部分只需要數據庫連接和會話 –