<tfoot id='czeRx'></tfoot>
    1. <legend id='czeRx'><style id='czeRx'><dir id='czeRx'><q id='czeRx'></q></dir></style></legend>

        <i id='czeRx'><tr id='czeRx'><dt id='czeRx'><q id='czeRx'><span id='czeRx'><b id='czeRx'><form id='czeRx'><ins id='czeRx'></ins><ul id='czeRx'></ul><sub id='czeRx'></sub></form><legend id='czeRx'></legend><bdo id='czeRx'><pre id='czeRx'><center id='czeRx'></center></pre></bdo></b><th id='czeRx'></th></span></q></dt></tr></i><div id='czeRx'><tfoot id='czeRx'></tfoot><dl id='czeRx'><fieldset id='czeRx'></fieldset></dl></div>

        <small id='czeRx'></small><noframes id='czeRx'>

        • <bdo id='czeRx'></bdo><ul id='czeRx'></ul>

        我如何修复此循环以使用引导程序轮播显示我的

        时间:2023-05-21
        <legend id='6vLum'><style id='6vLum'><dir id='6vLum'><q id='6vLum'></q></dir></style></legend>
        <tfoot id='6vLum'></tfoot>
          <bdo id='6vLum'></bdo><ul id='6vLum'></ul>

          1. <small id='6vLum'></small><noframes id='6vLum'>

              <tbody id='6vLum'></tbody>
              <i id='6vLum'><tr id='6vLum'><dt id='6vLum'><q id='6vLum'><span id='6vLum'><b id='6vLum'><form id='6vLum'><ins id='6vLum'></ins><ul id='6vLum'></ul><sub id='6vLum'></sub></form><legend id='6vLum'></legend><bdo id='6vLum'><pre id='6vLum'><center id='6vLum'></center></pre></bdo></b><th id='6vLum'></th></span></q></dt></tr></i><div id='6vLum'><tfoot id='6vLum'></tfoot><dl id='6vLum'><fieldset id='6vLum'></fieldset></dl></div>

                1. 本文介绍了我如何修复此循环以使用引导程序轮播显示我的数据库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我尝试使用 bootstrap carousel 来显示我的数据库中的图像,但我的循环似乎有问题......

                  message("<div class='btn sm-warning'>请选择一张图片.</div>");redirect_to('list_properties.php');}$id = $_GET['id'];$sql = "SELECT * FROM Pictures2 WHERE photo_id='$id';";$photos = 图片::find_by_sql($sql);?>

                  从数据库中获取的所有内容都是正确的,但在幻灯片中显示图像的循环显示一个图像,而幻灯片仅在第一张和第二张幻灯片之间循环.

                  <div class="row"><div id="carouselExampleIndicators" class="carousel slide mx-auto" data-ride="carousel"><ol class="carousel-indicators"><?php$i=0;如果(计数($照片)){foreach ($photos as $photo) {如果($i==0){echo '<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>';$i++;}别的{echo '<li data-target="#carouselExampleIndicators" data-slide-to="0"></li>';$i++;}}}?></ol><div class="carousel-inner"><?php$a=0;如果(计数($照片)){foreach ($photos as $photo) {如果($a==0){?><div class="carousel-item active"><img src="<?php echo $photo->image_path(); ?>"class="img-thumbnail img-responsive" alt="<?php echo $photo->title; ?>"/><?php$a++;}别的?>

                  <?php{?><div class="carousel-item"><img src="<?php echo $photo->image_path(); ?>"class="img-thumbnail img-responsive" alt="<?php echo $photo->title; ?>"/><?php$a++;}?>

                  <?php}}?>

                  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="sr-only">以前的</span></a><a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="sr-only">下一步</span></a>

                  解决方案

                  message("<div class='btn sm-warning'>请选择一张图片.</div>");redirect_to('list_properties.php');}$id = $_GET['id'];$sql = "SELECT * FROM Pictures2 WHERE photo_id='$id';";$photos = 图片::find_by_sql($sql);?>

                  .

                  <?php$i++;} 别的{如果($我!= 0){?><div class="carousel-item"><img src="<?php echo $photo->image_path(); ?>"class="img-thumbnail img-responsive" height="500" width="500" alt="<?php echo $photo->title; ?>"/>

                  <?php$i++;}}?>

                  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span><span class="sr-only">以前的</span></a><a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span><span class="sr-only">下一步</span></a>

                  I tried using bootstrap carousel to display images from my database but something seem to be wrong with my loop...

                  <?php
                    $message = "";
                    if(empty($_GET['id'])) {
                      $session->message("<div class='btn sm-warning'>please select an image.</div>");
                      redirect_to('list_properties.php');
                    } 
                    $id      = $_GET['id'];
                    $sql     = "SELECT * FROM pictures2 WHERE photograph_id='$id';";
                    $photos = Picture::find_by_sql($sql);
                  ?>
                  

                  The fetch is all correct from the database but the loop displaying the images in the slide displays one image and the slide loops between the first and second slide only.

                  <div class="container">
                  <div class="row">
                  <div id="carouselExampleIndicators" class="carousel slide mx-auto" data-ride="carousel">
                    <ol class="carousel-indicators">
                      <?php 
                       $i=0;
                      if(count($photos)){
                          foreach ($photos as $photo) {
                              if($i==0){
                                  echo '<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>';
                                  $i++;
                              }
                              else
                              {
                                  echo '<li data-target="#carouselExampleIndicators" data-slide-to="0"></li>';
                                  $i++;
                              }
                          }
                      }
                     ?>
                    </ol>
                    <div class="carousel-inner">
                     <?php
                      $a=0;
                      if(count($photos)){
                          foreach ($photos as $photo) {
                              if($a==0){
                                  ?>
                              <div class="carousel-item active">
                             <img src="<?php echo $photo->image_path(); ?>" class="img-thumbnail img-responsive"  alt="<?php echo $photo->title; ?>"/>
                              <?php   
                                  $a++;
                              }else
                              ?>
                      </div>
                             <?php
                              {
                                  ?>
                              <div class="carousel-item">
                             <img src="<?php echo $photo->image_path(); ?>" class="img-thumbnail img-responsive" alt="<?php echo $photo->title; ?>"/>
                                 <?php
                                  $a++;
                              }
                              ?>
                      </div>
                         <?php
                          }
                      }
                     ?>
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                      <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                      <span class="carousel-control-next-icon" aria-hidden="true"></span>
                      <span class="sr-only">Next</span>
                    </a>
                  </div>
                  </div>
                  </div>
                  

                  解决方案

                  <?php
                    $message = "";
                    if(empty($_GET['id'])) {
                      $session->message("<div class='btn sm-warning'>please select an image.</div>");
                      redirect_to('list_properties.php');
                    } 
                    $id      = $_GET['id'];
                    $sql     = "SELECT * FROM pictures2 WHERE photograph_id='$id';";
                    $photos = Picture::find_by_sql($sql);
                  ?>
                  

                  .

                  <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                  <ol class="carousel-indicators">
                   <?php
                  $i = 0; 
                   foreach($photos as $photo){
                          if($i == 0){
                  ?>
                  <li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" class="active"></li>
                  <?php
                   $i++;  }else{
                      if($i != 0){        
                  ?>
                  <li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" ></li>
                  <?php               
                          } $i++;
                      }
                   }
                  ?> 
                    </ol>
                    <div class="carousel-inner">
                     <?php 
                      $i = 0;  
                      foreach($photos as $photo){
                          if($i == 0){
                      ?>
                      <div class="carousel-item active">
                      <img src="<?php echo $photo->image_path(); ?>" class="img-thumbnail img-responsive" height="500" width="500" alt="<?php echo $photo->title; ?>"/>
                      </div>
                      <?php               
                      $i++;   } else{
                          if($i != 0){    
                      ?>
                      <div class="carousel-item">
                      <img src="<?php echo $photo->image_path(); ?>" class="img-thumbnail img-responsive" height="500" width="500" alt="<?php echo $photo->title; ?>"/>
                      </div>
                          <?php                           
                          } $i++;
                      }  
                        }
                      ?>
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                      <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                      <span class="carousel-control-next-icon" aria-hidden="true"></span>
                      <span class="sr-only">Next</span>
                    </a>
                  </div>
                  

                  这篇关于我如何修复此循环以使用引导程序轮播显示我的数据库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:带有子菜单的 PHP Bootstrap 4 导航菜单 下一篇:具有完整性和跨域性的 Wordpress 脚本

                  相关文章

                  最新文章

                  • <bdo id='9swX1'></bdo><ul id='9swX1'></ul>
                2. <small id='9swX1'></small><noframes id='9swX1'>

                  <legend id='9swX1'><style id='9swX1'><dir id='9swX1'><q id='9swX1'></q></dir></style></legend>

                3. <tfoot id='9swX1'></tfoot>

                      <i id='9swX1'><tr id='9swX1'><dt id='9swX1'><q id='9swX1'><span id='9swX1'><b id='9swX1'><form id='9swX1'><ins id='9swX1'></ins><ul id='9swX1'></ul><sub id='9swX1'></sub></form><legend id='9swX1'></legend><bdo id='9swX1'><pre id='9swX1'><center id='9swX1'></center></pre></bdo></b><th id='9swX1'></th></span></q></dt></tr></i><div id='9swX1'><tfoot id='9swX1'></tfoot><dl id='9swX1'><fieldset id='9swX1'></fieldset></dl></div>