我有两页cloth.php,第二页是pickup.php
在cloth.php上,我可以使用带有图像,价格和标题的复选框选择多个产品(来自数据库),并提交后重定向到包含产品详细信息的pickup.php页面。
所以我在pickup.php上得到一个数组(文本和图像的组合) 我可以使用
使用值foreach ($dada as $value) {
echo "<h1>$value<br></h1>";
}
我正在获取演示产品(产品名称),455(产品价格),image.jpg(产品图片)。 我在这里获得图像名称,但是我想显示图像,该怎么办?
注意:阵列中的行数每次都会根据产品的选择而变化。
请帮助 预先感谢
答案 0 :(得分:0)
过滤主图像数组并将其放入一个数组中,并从服务器获取路径并使用img标签显示它
$DisplayImages[0] = "Front with Hooks1.png";
$DisplayImages[1] = 8;
$DisplayImages[2] = "Back with Hooks";
$DisplayImages[3] = "bls 2.png";
$DisplayImages[4] = "Dart/Regular Blouse";
$DisplayImages[5] = 0;
$DisplayImages[6] = "5 Days deli.jpg";
$DisplayImages[7] = "Delivery in 5 days";
$DisplayImages[8] = 100;
$DisplayImages[9] = "Task-106-Add-Ons1.jpg";
$DisplayImages[10] = "Premium Cotton Lining";
$DisplayImages[11] = 150;
$supported_image = array(
'gif',
'jpg',
'jpeg',
'png'
);
echo ('<!DOCTYPE html>');
echo ('<html>');
echo ('<head>');
echo ('<title></title>');
echo ('</head>');
echo ('<body>');
foreach ($DisplayImages as $key => $value)
{
$ext = strtolower(pathinfo($value, PATHINFO_EXTENSION)); // Using strtolower to overcome case sensitive
if (in_array($ext, $supported_image))
{
//Give your server path of image here and Display it.
$ImgPath = "../I/Profiles".$value; // In this case I have image in my I folder profiles
echo ( '<img src='.$ImgPath.' alt="Image" height="42" width="42">');
}
else
{
echo $value; // Not an Image
}
}
echo ('</body>');
echo ('</html>');
// echo "<pre>";print_r($ImagePath);
// exit();