语法可能有错误:
.base64_encode($_SESSION[$row['PRODUCT_IMAGE]])
这应该从数据库中检索blob格式的产品图像。锚点将其链接到Productdetails.php
页面,其中显示了每个产品的描述。
我想分配一个关于从数据库中检索图像的会话,因此当用户点击产品时,他们会看到特定产品的描述。
此外,图像存储在列PRODUCT_IMAGE
中。感谢。
<?php
$query = mysqli_query($conn,"select * from products");
while($row = mysqli_fetch_array($query)) {
?>
<div class = "product-image-wrapper">
<a href = "Productdetails.php">
<?php echo '<img src = "data:image/jpeg;base64,'.base64_encode($_SESSION[$row['PRODUCT_IMAGE']]).'" alt = "" width = "250px" height ="300px"/>'; ?>
</a>
答案 0 :(得分:0)
更改为$_SESSION[$row['PRODUCT_IMAGE]]
至$row['PRODUCT_IMAGE']
并将$row['PRODUCT_IMAGE']
分配给会话变量
<?php
session_start();
$query = mysqli_query($conn,"select * from products");
while($row = mysqli_fetch_array($query)) {
$_SESSION['image']=$row['PRODUCT_IMAGE'];
?>
<div class = "product-image-wrapper">
<a href = "Productdetails.php">
<?php echo '<img src = "data:image/jpeg;base64,'.base64_encode($row['PRODUCT_IMAGE']).'" alt = "" width = "250px" height ="300px"/>'; ?>
</a>