使用php在一个幻灯片中显示两个图像

时间:2016-09-26 18:49:48

标签: 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

的下一个数据

1 个答案:

答案 0 :(得分: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; ?>

如果您发布此内容会有什么输出?