gpt4 book ai didi

php - 从保存在 SQL 数据库中的路径数据中检索图像

转载 作者:可可西里 更新时间:2023-11-01 01:02:57 26 4
gpt4 key购买 nike

我从 SQL 数据库中检索商店图像和内容的部分代码(只有路径保存在数据库中)如下。我得到显示的内容,除了图像。

我的数据库记录说路径为; C:/xampp/htdocs/bro/productLoader/uploaded_files/1377935517-IMG_0150.JPG

我输入的图片来源似乎对我没有帮助。如何调整我的方法以确保从数据库中提取图片?

代码如下;

<?php
$j=0;
while ($rows = mysql_fetch_assoc($query))
{
?>
<tr style="height:100px; font-family: Georgia, 'Times New Roman', Times, serif;">
<td style=" width:100px;">
<img src='<?php $rows['pictures'];?>'><br><br>
</td>
<td style="text-align:justify;"><?php echo $rows['description'];?><br><br></td>
<td style="text-align:right;"><?php echo $rows['brand'];?><br><br></td>
<td style="text-align:right;"><?php echo $rows['model'];?><br><br></td>
<td style="text-align:right;"><?php echo $rows['unitprice'];?><br><br></td>
<td style="text-align:right;"><?php echo $rows['availability'];?> units available<br><br></td>
<td><input type='submit' id='buynow[]' class='buynow' name='but' value='Buy'><br><br></td>
</tr>
<?php
$j++;
}
echo "</table>";
}?>

最佳答案

您必须仅插入不包括文档根目录的相对路径。也就是说,如果您的文档根目录设置为仅 htdocs 文件夹(这在本地主机的 apache 中是默认设置),那么您必须在您的案例中从该文档根目录插入图像路径

/bro/productLoader/uploaded_files/1377935517-IMG_0150.JPG

是的,您也需要回显该变量。

关于php - 从保存在 SQL 数据库中的路径数据中检索图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18545997/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com