Php 在slider Codeigniter中显示图像

Php 在slider Codeigniter中显示图像,php,codeigniter-3,Php,Codeigniter 3,嗨,我使用codeigniter来编写简单的清单脚本。我有一个多图像上传每个清单5图像。。。 但我在列表详细信息页面中显示有问题 我在media中有两个表properties和media有3列idproperty\u id(与properties.id和photo相同)(这是图像名称+扩展名) 控制器:Properties.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class P

嗨,我使用codeigniter来编写简单的清单脚本。我有一个多图像上传每个清单5图像。。。 但我在列表详细信息页面中显示有问题

我在
media
中有两个表
properties
media
有3列
id
property\u id
(与
properties.id
photo
相同)(这是图像名称+扩展名)

控制器:Properties.php

 <?php
 defined('BASEPATH') OR exit('No direct script access allowed');

class Properties extends My_Controller {

public function __construct(){
    parent::__construct();
    $this->load->model('Property');
}
public function details($slug){
    $this->data['listing'] = $this->Property->find_by_slug($slug);
    $this->load_theme('properties/details');
}

}
  <?php
   defined('BASEPATH') OR exit('No direct script access allowed');

    class Property extends CI_Model{

var $table = 'properties';

function find_by_slug($slug){
    $this->db->select('properties.*,users.*,media.photo');
    $this->db->join('users', 'users.id = properties.user_id');
    $this->db->join('media', 'media.property_id = properties.id');
    $this->db->where('slug',$slug);
    return $this->db->get($this->table,1)->row_array();
}
}
                            <div class="carousel-inner">

                                 <div class="item active">
                                        <?php $x = 0; ?>
                  <?php if($listing):?>
                <?php foreach ($listing as $m):?>
                <?php $x++ ; ?>
                                 <div class="item <?php if ($x == 1) echo 'active' ?>">
                                    <img src="<?php echo site_url('files/listing/'.$m['photo'])?>" class="thumb-preview" alt="<?php echo $m['alt'];?>">
                                    </div>

                 <?php endforeach;?>
              <?php endif;?>
              </div>

">

我不明白为什么它不在滑块中显示图像…

如果在配置中,
site\u url()
可以在末尾显示
index.php
。这会破坏图像url

如果需要访问资源,请始终使用
base\u url()

更改:

site_url('files/listing/'.$m['photo']); 
至:

base_url('files/listing/'.$m['photo']);

我想问题是它找不到合适的id

我想你在foreach循环之外有一个额外的项。我错了吗?顺便说一下,你不必定义$x来获得索引1,你可以做foreach($key=>$m)并使用$key来获得索引。不,我尝试使用$key但不起作用。。。