【发布时间】:2013-11-28 16:03:24
【问题描述】:
所以这是视图的代码。由于某种原因,想象没有显示。 Var_dumping $oProduct->img_path 返回(我修改了这些路径以进行测试,因为我正在使用更多的数据库条目):
'W:/wamp/www/repos/adicris/imgs/products/logo.jpg' (one element)
'imgs/products/logo.jpg' (some other element)
'/imgs/products/logo.jpg' (some other element)
adicris 是包含整个项目的文件夹。
如您所见,我尝试为其提供完整路径和相对路径,但没有成功。
PS:图片名称拼写正确,它确实允许jpg,并且在正确的文件夹中。
<?php foreach ($aProducts->result() as $oProduct): ?>
<tr>
<td><?=$oProduct->pid?></td>
<td><?=$oProduct->name?></td>
<td><img scr=<?=$oProduct->img_path?>></td>
<td><?=$oProduct->price?></td>
<td><?=$oProduct->description?></td>
<td><?=$oProduct->type_name?></td>
</tr>
<?php endforeach ?>
我在 img 行也试过这个:
<td><img scr="<?=base_url()?><?=$oProduct->img_path?>></td>
无论 img_path 格式如何,所有条目都失败。
【问题讨论】:
-
缺少“尝试
<img scr="<?=base_url()?><?php echo $oProduct->img_path?>"> -
我想你会发现它是
src。 -
我不敢相信我花了两个小时才意识到我写的是 scr 而不是 src。你应该留下你的地址,我会给你邮寄啤酒,哈哈。非常感谢。
-
最小的东西。 :) 祝你好运。
标签: php html codeigniter wamp