2016-09-26 31 views
0

我正在處理一個應用程序,其中我在自舉中創建了一個滑塊,但在滑塊中有一個幻燈片放映中顯示兩個圖像,因此我寫了一個簡單的select查詢以獲取記錄,但問題是,它顯示同一圖像上的箱子,我不知道我怎麼能在一個循環使用php在一個幻燈片中顯示兩個圖像使用php

在這裏得到下一個數據是代碼

<div class="carousel-inner">   
    <?php if($blog) : $counter = 0; foreach($blog as $blogs) : $counter++; ?> 
    <?php if($counter === 1) : ?> 
    <div class="item active"> 
    <?php else : ?> 
    <div class="item"> 
    <?php endif; ?> 
     <div class="row"> 
      <div class="col-md-6"> 
       <div class="panel"> 
        <div class="panel-heading"> 
         <h3> 
          <a href="#"> <?php echo substr($blogs -> heading, 0, 30); ?> </a> <br> <br> <br> 
          <p> <?php echo substr($blogs -> description, 0, 300); ?> <br><br> 
          <a href="#" class="link">Read the full story</a> </p><br> 
          <img src="<?php echo base_url().$blogs -> image; ?>"> 
         </h3> 
        </div> 
       </div> 
      </div> 
      <div class="col-md-6"> 
       <div class="panel"> 
        <div class="panel-heading"> 
         <h3> 
          <a href="#"> <?php echo substr($blogs -> heading, 0, 30); ?> </a> <br> <br> <br> 
          <p> <?php echo substr($blogs -> description, 0, 300); ?> <br><br> 
          <a href="#" class="link">Read the full story</a> </p><br> 
          <img src="<?php echo base_url().$blogs -> image; ?>"> 
         </h3> 
        </div> 
       </div> 
      </div> 
     </div><!--.row--> 
    </div><!--.item--> 
    <?php endforeach; endif; ?> 

</div><!--.carousel-inner--> 
    <a data-slide="prev" href="#blog" class="left carousel-control">‹</a> 
    <a data-slide="next" href="#blog" class="right carousel-control">›</a> 
</div><!--.Carousel--> 

enter image description here

以上是結果但我希望第二個圖像成爲下一個數據DB

+0

檢查$博客是否有不同的輸出 - >標題vs $博客[1] - >標題 – Danimal

+0

nop它顯示錯誤 –

+0

什麼是您的博客平臺? – Danimal

回答

0

試試這個:

<div class="carousel-inner">   
<?php if($blog) : $counter = 0; foreach($blog as $blogs) : $counter++; ?> 
<?php if($counter === 1) : ?> 
<div class="item active"> 
<?php else : ?> 
<div class="item"> 
<?php endif; ?> 
    <div class="row"> 
     <div class="col-md-6"> 
      <div class="panel"> 
       <div class="panel-heading"> 
        <h3> 
         <a href="#"> <?php echo substr($blogs -> heading, 0, 30); ?> </a> <br> <br> <br> 
         <p> <?php echo substr($blogs -> description, 0, 300); ?> <br><br> 
         <a href="#" class="link">Read the full story</a> </p><br> 
         <img src="<?php echo base_url().$blogs -> image; ?>"> 
        </h3> 
       </div> 
      </div> 
     </div> 
    <?php endforeach; endif; ?> 

什麼輸出,如果你張貼此?

+0

好吧,如果我確實停止循環,我將如何在一張幻燈片中顯示2張圖片,輸出結果將如下http://i.stack.imgur.com/9EEhj.png –

+0

第二幅圖像不應該與第一 –

相關問題