我正在尝试使用 PDO 概念从我的产品表中获取产品。不知道怎么根据ID取图片?
以下是我在脚本中包含的内容。
require 'includes/db.con.php';
try {
$id= $_GET['id'];
$query = $conn-> prepare("SELECT * FROM PRODUCTS WHERE id ?");
$query ->execute(array($id));
$data= $query->fetchAll(PDO::FETCH_ASSOC);
} catch(PDOException $e){
echo $e->getMessage();
}
?>
<html>
<head lang="en-GB" dir="ltr">
<meta charset="utf-8">
<title>Men's Shoes</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="products.css">
</head>
<body>
<!---section content-->
<section>
<h2>men's shoes</h2>
</section>
<!--- Shoes -->
<main id="maincontent">
<figure>
<img src="img/men_shoes/brown_suede_shoes.jpg" alt="brown suede shoes"></a>
<blockquote><b>£40.00</b></blockquote>
<figcaption>Brown Suede Shoes</figcaption>
</figure>