"name"개체를 표시하려고하지만 작동하지 않습니다. foreach를 잘못 사용하고있는 것처럼 보입니다. $ a에 대해 print_r을 사용하고 배열을 표시합니다. 누군가 도와 줄 수 있어요.배열에 foreach를 사용하는 방법
public function product(){
$st = $this->db->prepare("select id, name, description, price from deals where quantity > 0 order by id desc");
$st->execute();
if ($st->rowCount() == 0){
echo "There are no products to display";
} else {
$a = $st->fetch(PDO::FETCH_OBJ)
foreach ($a as $products){
echo $products->name;
}
}
}