我在这里面临这个问题。我想通过从另一个表中获取其项目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