我在這裏面臨這個問題。我想通過從另一個表中獲取其項目ID來顯示項目的名稱。以下是代碼
我有問題,當我嘗試使用「。$ obj [0] - >名稱顯示名稱。」在for循環的第一行。注意:試圖獲得非物件的財產
$objClass = array();
$objClass1 = array();
$obj= array();
$object = new product();
$objLogic = new customerLogic();
$objLogic1 = new customerLogic();
$objL= new productLogic();
$objClass[0]= new stdClass;
$objClass1[0]= new stdClass;
$obj[0]= new stdClass;
$objClass[0]->custId = $_GET['id'];
$objClass1[0]->custId = $_GET['id'];
$objClass = $objLogic->getSaleRecord_customer($objClass[0]);
$objClass1 = $objLogic1->getName_customer($objClass1[0]);
$object->itemId = $objClass[0]->itemId;
$obj =$objL->getName_product($object->itemId);
// echo $objClass1[0]->firstName;
$i=1;
foreach($objClass as $customer) {
echo "<tr><td class=\"inner_text\">$customer->reciept</td><td align=\"center\">".$obj[0]->name."</td>";
echo "<td align=\"center\">".$objClass1[0]->firstName." ".$objClass1[0]->lastName."</td><td align=\"center\">";
echo "$customer->weight</td>
<td align=\"center\">$customer->costPerKg</td>
<td align=\"center\">$customer->cost</td>
<td align=\"center\">$customer->payed</td>
<td align=\"center\">$customer->remaining</td></tr>";
$i++;
}
?>
</table>
這就是我使用 公共職能getName_product功能($對象) \t { \t \t $ dbHandler =新DBCONFIG(); \t \t $ query =「select item from product where itemId = $ object」; \t \t $ results = $ dbHandler-> Query($ query); \t \t return $ results; \t} – talhaMalik22 2012-01-14 22:11:45
你確定這給你一個對象表示而不是關聯數組嗎?你有沒有試過'$ obj [0] ['name']'? – 2012-01-14 22:14:40
哇..它不再顯示錯誤,但它也顯示了名稱?你能看到這裏的任何問題 – talhaMalik22 2012-01-14 22:17:52