嗨,我正在尝试echo
使用产品的名称,Product Table
但取而代之的是它echo
的名称Category table
。除了更改两张表之一的名称之外,它们是否是一种阻止这种情况的方法?
Table: Product
Pid Name
1 man
2 woman
3 child
Table: Category
CatID Name Pid
1 pen 1
2 pen 1
3 pencil 2
3 red_pen 3
Table: active_product
ATpid size pid price
1 12 1 10
2 14 2 15
3 16 3 20
4 18 4 30
PDO:
$stmt = $conn->prepare("
SELECT Product.Name, Category.Name, size, Price
FROM active_Product, Product, Category
WHERE Product.ProdID ='$item_id'
AND size = '$size '
AND Category.Name = '$pcategory'
Limit 1");
$stmt->bindParam('$item_id',$item_id);
$stmt->bindParam('$size',$size);
$stmt->bindParam('$pcategory',$pcategory);
$stmt->execute();
foreach($stmt->fetchAll(PDO::FETCH_ASSOC) as $row ){
$product_name = $row["Name"];