<?php
$hint = 'dell';
$sql="SELECT p.`entity_id`, pv.`value` as name,
GROUP_CONCAT(DISTINCT(pm.`value`) SEPARATOR ', ') as imagesPath
FROM `catalog_product_entity` as p
INNER JOIN `catalog_product_entity_varchar` as pv
ON pv.`entity_id` = p.`entity_id` and pv.`attribute_id` = 71
LEFT JOIN `catalog_product_entity_media_gallery` as pm
ON pm.`entity_id` = p.`entity_id` and pm.`attribute_id` = 88
WHERE pv.value LIKE '".$hint."'";
foreach($readConnection->fetchAll($sql) as $orders) {
?>
<img src="<?php echo Mage::getBaseUrl('media').'catalog/product'. $orders["imagesPath"].''; ?>" alt="" />
<?php
}
?>
此代码的输出是
<img src="http://127.0.0.1/magento/media/catalog/product/2/_/2.jpg" alt="" />
它只显示了图像的路径,但我希望在浏览器的输出中显示图像。