doubo4336 2016-02-23 07:54
浏览 63

我想根据所选的category_id仅显示这些图像

i want to display only those images according to the category_id selected but iam not getting images here and and for all category_id the value showing is category_id=9

here is my controller

 public function men_clothing($p_id=null) 
{
    $data['active_mn']='men_clothing';

    $data['men']=$this->roxmodel->get_category_by_parent($p_id=8);
    $data['kids']=$this->roxmodel->get_category_by_parent($p_id=9);

    $config['base_url'] = base_url().'roxcontrol/men_clothing';
    $config['per_page'] = 9;
    $config['uri_segment'] = 3;
    $config['total_rows'] = $this->roxmodel->count_gallery();
    $data['galllery']=$this->roxmodel->get_gallery_men_images($p_id,$config['per_page'],$this->uri->segment(3));

    var_dump($data['galllery']);
    $this->load->library('pagination',$config);
    $data['page_links'] = $this->pagination->create_links();

    $this->load->view('men_clothing',$data);
}

here is my model

public function get_gallery_men_images($p_id=null)
  {
    $this->db->where('gallery.category_id',$p_id);
    $this->db->select('gallery.*,category.category_name');
    $this->db->join('category','category.id=gallery.category_id');
    return $this->db->get('gallery')->result();

  }

here is my view page

<ul class="sidebar-tags">
      <li><a href="<?php echo base_url();?>roxcontrol/men_clothing">View All  </a></li>
     <?php foreach($men as $row) {?>
      <li><a href="<?php echo base_url();?>roxcontrol/men_clothing/<?php echo $row->id; ?>"><?php echo $row->category_name; ?> <span> </span></a></li>
     <?php } ?>
</ul>



 <?php if( !empty($galllery) ) {
                                foreach($galllery as $row){?>

                                    <div class="col-lg-4 col-md-4 col-sm-4">
                                        <div class="two-product">


                                            <!-- single-product start -->
                                            <div class="single-product">
                                            <!--    <span class="sale-text">Sale</span>-->
                                                <div class="product-img">
                                                    <a href="#">
                                                        <img class="primary-image" ima="<?php echo base_url();?>images/<?php echo $row->image;?>" src="<?php echo base_url();?>images/<?php echo $row->image;?>" alt="" />
                                                        <img class="secondary-image" ima="<?php echo base_url();?>images/<?php echo $row->image;?>" src="<?php echo base_url();?>images/<?php echo $row->image;?>" alt="" />

                                                    </a>
                                                    <div class="action-zoom">
                                                        <div class="add-to-cart">
                                                            <a href="<?php echo base_url()?>images/<?php echo $row->image ?>" data-toggle="modal-image"  title="Quick View"><i class="fa fa-search-plus"></i></a>
                                                        </div>
                                                    </div>

                                                <!--    <div class="price-box">
                                                        <span class="new-price">$110.00</span>
                                                    </div>-->
                                                </div>
                                                <div class="product-content">
                                                    <h2 class="product-name"><a href="<?php echo base_url();?>roxcontrol/product_details/<?php echo $row->id;?>/<?php echo $row->category_id;?>"><?php echo $row->title;?></a></h2>
                                                    <p><?php echo $row->description;?></p>
                                                </div>
                                            </div>

                                            <!-- single-product end -->
                                        </div>
                                    </div>
                                    <?php }}?>

here the image is not displaying and getting like this

SELECT `gallery`.*, `category`.`category_name` FROM `gallery` JOIN `category` ON `category`.`id`=`gallery`.`category_id` WHERE `gallery`.`category_id` = 9

my table(gallery) looks like this

id     image                category_id         
93   img1455604030.jpg       10              
94   img1455605183.jpg       11               
95   img1455616291.jpg       11                
96   img1455617201.jpg       10                
97   img1455617299.jpg       10                
98   img1455681918.jpg       13              
99   img1455681957.jpg       12  
  • 写回答

2条回答 默认 最新

  • dtml3340 2016-02-23 08:11
    关注

    there is a problem in you join query

    $this->db->select('*');
    $this->db->from('gallery');
    $this->db->where('category.id',$p_id);
    $this->db->join('category', 'category.id = gallery.category_id');
    
    
    $query = $this->db->get()->result();
    return $query;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大