【问题标题】:HTML Img failing to show. Using WAMP server + CodeIgniterHTML Img 无法显示。使用 WAMP 服务器 + CodeIgniter
【发布时间】: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 格式如何,所有条目都失败。

【问题讨论】:

  • 缺少“尝试&lt;img scr="&lt;?=base_url()?&gt;&lt;?php echo $oProduct-&gt;img_path?&gt;"&gt;
  • 我想你会发现它是src
  • 我不敢相信我花了两个小时才意识到我写的是 scr 而不是 src。你应该留下你的地址,我会给你邮寄啤酒,哈哈。非常感谢。
  • 最小的东西。 :) 祝你好运。

标签: php html codeigniter wamp


【解决方案1】:
<td><img src="<?=base_url()?><?=$oProduct->img_path?>"></td>
         ^^^ Not scr.

也不要忘记标记属性的引号。虽然它适用于大多数浏览器,但它无效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 2014-01-17
    • 1970-01-01
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多