使用codeigniter创建图库时出错 [英] error in creating gallery using codeigniter

查看:36
本文介绍了使用codeigniter创建图库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





<我已经粘贴了我的数据库的两个屏幕截图,以及我希望我的网页看起来如何。即时通讯试图做到这一点,但没有得到如何解决问题
i已将所有图像存储在文件夹中以及图像路径在数据库中,现在我想以一种方式获取图像,当我单击所有作品都应显示所有图像,但是当我单击诸如此类的创意,摄影或网络开发时,它应仅显示与存储在数据库中的类相关的那些图像,其类型为列。或者,例如,如果我单击说创意,那么它应该像这样显示第二,第三,第五和第八。我真的不知道该怎么做。请我真的需要帮助

  // -----控制器------ 

公共功能组合()
{
$ this-> load-> helper('url');
$ this-> load-> view(’header’);
$ data [’results]] = $ this-> Contact_model-> getAllRecords3();
$ this-> load-&view;'portfolio',$ data);
$ this-> load-> view('footer');
}


// --------模型-----

函数getAllRecords3()
{
return $ this-> db-> get('portfolio1')-> result();
}


// -------视图---------

< section id =公文包
< div class = container>
< div class = center>
< p> Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt< / p>
< / div>

< ul class = portfolio-filter text-center>
< li>< a class = btn btn-default active href =# data-filter = *> All Works< / a>< / li>
< li>< a class = btn btn-default href =# data-filter =。bootstrap> Creative< / a>< / li>
< li>< a class = btn btn-default href =# data-filter =。html>摄影< / a>< / li>
< li>< a class = btn btn-default href =# data-filter =。wordpress> Web Development< / a>< / li>
< / ul>
<!-/#portfolio-filter->
< / div>
< div class = container>
< div class =>
< div class = portfolio-items>

<?php
if(!empty($ results)){

foreach($ result as $ row){?>
< div class = portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3>
< div class = recent-work-wrap>
< img class = img-sensitive src =<?php echo base_url(’uploads /’.$ row-> filename);?> alt =>
< div class = overlay>
< div class = recent-work-inner>
< h3>< a href =#><?php echo $ row-> first_content; α/ a 3 = 1。
< p><?php echo $ row-> second_content; && lt; / p>
< a class = preview href =<?php echo base_url(’uploads /’.$ row-> filename);?> rel = prettyPhoto>< i class = fa fa-eye>< / i>查看< / a>
< / div>
< / div>
< / div>
< / div>
<?php

}?>

<?php}
?>


< / div>
< / div>
< / div>
< / section>




< ;!-jQuery(Bootstrap的JavaScript插件必需)->
< script src =<?php echo base_url();?> js / jquery-2.1.1.min.js>< / script>
< ;!-包括所有已编译的插件(如下),或根据需要包括单个文件->
< script src =<?php echo base_url();?> js / bootstrap.min.js>< / script>
< script src =<?php echo base_url();?> js / jquery.prettyPhoto.js>< / script>
< script src =<?php echo base_url();?> js / jquery.isotope.min.js>< / script>
< script src =<?php echo base_url();?> js / wow.min.js>< / script>
< script src =<?php echo base_url();?> js / functions.js>< / script>


解决方案

请尝试以下解决方案。



您错过了添加div之类的动态类,例如应用 joomla

 < div class = portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3> 

在上面用您现有的代码添加的类

 <?php 
foreach($ result as $ row){
//从数据库获取动态类名的代码
$ class = explode( ,.,$ row-> type);
$ gettypes = implode(,$ class);
?>
< div class = portfolio-item<?php echo $ gettypes;?> col-xs-12 col-sm-4 col-md-3>

希望这项工作!


i have pasted some two screen shoots of my database and how actually i want my web page to look. im trying to get this done but not getting how to solve the issue i have stored all the images in folder and also the image path in the database, now i want to fetch the image in such a way that when i click the all works it should display all the images but when i click creative or photography or web development like this then it should show only those images which are related to their classes stored in database with type as column. alternatively for example if i click say creative then it should display 2nd, 3rd, 5th and 8th like this.i really don have any idea how to do this. please i really need help

            //-----controller------

            public function portfolio()  
            {  
            $this->load->helper('url');
            $this->load->view('header');
                $data['results'] = $this->Contact_model->getAllRecords3();
            $this->load->view('portfolio',$data); 
            $this->load->view('footer');    
            }


            //--------model-----

            function getAllRecords3()
            {
                return  $this->db->get('portfolio1')->result();
            }


            //-------view---------

            <section id="portfolio">
        <div class="container">
          <div class="center">
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt</p>
          </div>

          <ul class="portfolio-filter text-center">
            <li><a class="btn btn-default active" href="#" data-filter="*">All Works</a></li>
            <li><a class="btn btn-default" href="#" data-filter=".bootstrap">Creative</a></li>
            <li><a class="btn btn-default" href="#" data-filter=".html">Photography</a></li>
            <li><a class="btn btn-default" href="#" data-filter=".wordpress">Web Development</a></li>
          </ul>
          <!--/#portfolio-filter-->
        </div>
        <div class="container">
          <div class="">
            <div class="portfolio-items">

            <?php 
                if( !empty($results) ) {

                    foreach($results as $row) {?>
                    <div class="portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3">
                    <div class="recent-work-wrap">
                      <img class="img-responsive" src="<?php echo base_url('uploads/'.$row->filename);?>" alt="">
                      <div class="overlay">
                          <div class="recent-work-inner">
                      <h3><a href="#"><?php echo $row->first_content; ?></a></h3>
                      <p><?php echo $row->second_content; ?></p>
                      <a class="preview" href="<?php echo base_url('uploads/'.$row->filename);?>" rel="prettyPhoto"><i class="fa fa-eye"></i> View</a>
                      </div>
                        </div>  
                    </div> 
                    </div> 
                   <?php 

                   } ?>

                <?php }
            ?>


                </div>
              </div>
            </div>
          </section>




              <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
              <script src="<?php echo base_url(); ?>js/jquery-2.1.1.min.js"></script>
              <!-- Include all compiled plugins (below), or include individual files as needed -->
              <script src="<?php echo base_url(); ?>js/bootstrap.min.js"></script>
              <script src="<?php echo base_url(); ?>js/jquery.prettyPhoto.js"></script>
              <script src="<?php echo base_url(); ?>js/jquery.isotope.min.js"></script>
              <script src="<?php echo base_url(); ?>js/wow.min.js"></script>
              <script src="<?php echo base_url(); ?>js/functions.js"></script>

解决方案

Please try below solution.

You have missed dynamic classes adding in div like apps and joomla

<div class="portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3">

added class in above line with your existing code

<?php
foreach($results as $row) {
//code for getting dynamic class names from db
$class = explode(",.", $row->type);
$gettypes = implode(" ", $class); 
?>
<div class="portfolio-item <?php echo $gettypes;?> col-xs-12 col-sm-4 col-md-3">

Hope this work!

这篇关于使用codeigniter创建图库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆