doz97171 2016-09-26 18:49
浏览 13

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

I am working on an application where i have a slider made in bootstrap but in slider there are two images in one slide show instead of one, so i have wrote a simple select query to get record but the problem is that it showing same images on boxes, i dont know how i can get next data in one loop

here is the code

    <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

the above is the result but i want the second image to be the next data from db

  • 写回答

1条回答 默认 最新

  • dongsuo0517 2016-09-26 18:57
    关注

    try this:

     <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; ?>
    

    What outputs if you post this?

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析