【问题标题】:zend framework display image using to field in a rowzend 框架使用 to 连续显示图像
【发布时间】:2012-08-20 13:11:35
【问题描述】:

我已将图像添加到数据库,使用目录路径作为一行中的一个字段,并将文件扩展名作为一行中的另一个字段。

表格代码:

CREATE TABLE chinaletting (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    category TEXT NOT NULL,
    title TEXT NOT NULL,
    image BLOB NOT NULL,
    imageext TEXT NOT NULL,
    floorroom TEXT NOT NULL,
    spacesize TEXT NOT NULL,
    available TEXT NOT NULL,
    contactname TEXT NOT NULL,
    contactnumber TEXT NOT NULL,
    email VARCHAR(32) NOT NULL DEFAULT 'noemail@test.com'
);
CREATE INDEX "id" ON "chinaletting" ("id");

表格显示:

<dl>
    <?php foreach ($this->entries as $entry): ?>
    <dt><?php echo $this->escape($entry->category) ?></dt>
    <dd><?php echo $this->escape($entry->title) ?></dd>
    <dd><?php echo $this->escape($entry->image), $this->escape($entry->imageext)  ?></dd>
    <dd><?php echo $this->escape($entry->floorroom) ?></dd>
    <dd><?php echo $this->escape($entry->spacesize) ?></dd>
    <dd><?php echo $this->escape($entry->available) ?></dd>
    <dd><?php echo $this->escape($entry->contactname) ?></dd>
    <dd><?php echo $this->escape($entry->contactnumber) ?></dd>
    <dd><?php echo $this->escape($entry->email) ?></dd>
    <?php endforeach ?>
</dl>

屏幕显示:

真正要显示的是图片,谁能帮忙

【问题讨论】:

  • 使用标签显示图片。
  • 谢谢我现在的问题是我只想在表格中显示适合太平洋类别的行你知道怎么做吗x
  • 不确定,也许使用if-else

标签: database image zend-framework echo


【解决方案1】:

试试:

<dl>
    <?php foreach ($this->entries as $entry) {
      if($this->escape($entry->category) == 'pacific') { ?>
        <dt><?php echo $this->escape($entry->category) ?></dt>
        <dd><?php echo $this->escape($entry->title) ?></dd>
        <dd><img src="<?php echo $this->escape($entry->image), $this->escape($entry->imageext)  ?>"></dd>
        <dd><?php echo $this->escape($entry->floorroom) ?></dd>
        <dd><?php echo $this->escape($entry->spacesize) ?></dd>
        <dd><?php echo $this->escape($entry->available) ?></dd>
        <dd><?php echo $this->escape($entry->contactname) ?></dd>
        <dd><?php echo $this->escape($entry->contactnumber) ?></dd>
        <dd><?php echo $this->escape($entry->email) ?></dd>
    <?php }} ?>
</dl>

对于 2 个类别:

<dl>
    <?php foreach ($this->entries as $entry) {
      if($this->escape($entry->category) == 'shoes' || $this->escape($entry->category) == 'dress') { ?>
        <dt><?php echo $this->escape($entry->category) ?></dt>
        <dd><?php echo $this->escape($entry->title) ?></dd>
        <dd><img src="<?php echo $this->escape($entry->image), $this->escape($entry->imageext)  ?>"></dd>
        <dd><?php echo $this->escape($entry->floorroom) ?></dd>
        <dd><?php echo $this->escape($entry->spacesize) ?></dd>
        <dd><?php echo $this->escape($entry->available) ?></dd>
        <dd><?php echo $this->escape($entry->contactname) ?></dd>
        <dd><?php echo $this->escape($entry->contactnumber) ?></dd>
        <dd><?php echo $this->escape($entry->email) ?></dd>
    <?php }} ?>
</dl>

【讨论】:

  • 嗨,我将如何在上面进行编辑以使其显示到数据库的类别中。:
  • @Zara_tj,不确定我是否理解,您能否详细说明您想要达到的目标?
  • 下面会显示所有鞋类的记录:if($this->escape($entry->category) == 'shoes')。例如,我想添加到此以展示鞋子 + 连衣裙
  • @Zara_tj,我添加了 2 个类别的代码。这真的是基本的 PHP。您应该阅读 PHP 教程并尝试一些事情。然后,人们会很乐意在这里为您提供帮助。这是我刚刚发现的一个可以帮助您了解基本编程语法的方法:freewebmasterhelp.com/tutorials/PHP
猜你喜欢
  • 1970-01-01
  • 2010-11-15
  • 2011-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多