0

这是我从数据库中提取的数组:

Array
(
[0] => stdClass Object
    (
        [id] => 88
        [category] => banners
        [project] => projectname
        [location] => thames
        [image] => DSC02588.JPG
        [imagepath] => 
        [lastrun] => 2012-07-05 03:04:11
    )

[1] => stdClass Object
    (
        [id] => 89
        [category] => logos
        [project] => projectname
        [location] => auckland
        [image] => rounded_corners.jpg
        [imagepath] => 
        [lastrun] => 2012-07-05 03:04:11
    )

[2] => stdClass Object
    (
        [id] => 90
        [category] => logos
        [project] => projectname
        [location] => auckland
        [image] => DSC02586.JPG
        [imagepath] => 
        [lastrun] => 2012-07-05 03:04:11
    )

[3] => stdClass Object
    (
        [id] => 91
        [category] => logos
        [project] => projectname
        [location] => auckland
        [image] => 2-03-2012 11-54-42 a.m..jpg
        [imagepath] => 
        [lastrun] => 2012-07-05 03:04:11
    )

)

我需要能够像这样将其输出到 html 中:

<?php foreach ($query as $row){ ?>          
        <div class="project grid_2 left">
            <a class="logothumb" href="javascript:void(0)">
            <div class="loading"></div>
            <img class="thumb" src="<?php echo base_url('assets/images') ?>/logo-thumb.jpg" width="135" height="105" alt="logo">
            <div class="imagecopy"><p><span>Brand Name</span><br>Location</p></div>
            <div class="hidden projectname"><?php echo $row->project; ?></div>
            <div class="hidden projectlocation"><?php echo $row->location; ?></div>
            <ul class="hidden imagelist">
                <li><img src="<?php echo base_url('assets/images') ?>/<?php echo $row->image; ?>" ></li>
              <li><img src="<?php echo base_url('assets/images') ?>/<?php echo $row->image; ?>" ></li>
            </ul>
          </a>
        </div>

感谢您的任何建议和帮助

编辑:我正在使用 codeignitor

在我的模型中,此时很简单:

public function get_portfolio()
{
        $query = $this->db->get('portfolio');
        return $query->result();
       }

我要完成的是类别->项目(按同一项目分组)->位置(按同一位置分组)->及其图像

以下是数据的样子:

88横幅项目名称位置1 DSC02588.JPG 2012-07-05 03:04:11

89 标志项目名称奥克兰 rounded_corners.jpg 2012-07-05 03:04:11

90 个标志 projectname2 auckland DSC02586.JPG 2012-07-05 03:04:11

91 个徽标项目名称奥克兰 2-03-2012 11-54-42 am.jpg 2012-07-05 03:04:11

这是表格:

  CREATE TABLE `portfolio` (
  `id` int(11) NOT NULL auto_increment,
  `category` varchar(50) NOT NULL,
  `project` varchar(50) NOT NULL,
  `location` varchar(50) NOT NULL,
  `image` varchar(50) NOT NULL,
  `lastrun` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=92 DEFAULT CHARSET=utf8;
4

0 回答 0