dongyang2229 2019-01-01 09:13
浏览 55
已采纳

如何使用bootstrap 4从数据库中显示3列动态数据

Following is my code I am displaying details as 3 columns per row using Bootstrap class row.

I tried like changing div and some condition

<div class="container">
  <?php

  if($lclResult->rowCount() > 0){
    while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
      # code...
      $lclUserName = $row['us_business_name'];
      $lclImage1 = $row['us_image1'];
      $lclCategory = $row['us_category'];
      $lclArea = $row['us_area'];

  ?>
  <div class="row">
    <div class="col-sm-4">
      <div class="card">
        <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
        <div class="card-body">
          <h4 class="card-title"><?php echo $lclUserName?></h4>
          <p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
          <hr>
          <i class="fa fa-map-marker" style="font-size: 23px;"><span>&nbsp;&nbsp;</span><?php echo $lclArea?></i>
          <!-- <a href="#" class="btn btn-primary">See Profile</a> -->

        </div>
      </div>


 <?php
  }
  ?>
 </div>
 <?php
 } else { 
 ?>
<div class="container">
 <div class="row">
  <div class="col-sm-12">
    <h1> NO RESULT FOUND...</h1>
  </div>
 </div>
</div>

<?php
   }
?>


   </div>  
 </div>

I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.

  • 写回答

1条回答 默认 最新

  • duafagm1066 2019-01-01 09:33
    关注

    Change your code like this

    <div class="container">
      <div class="row">
        <?php
    if($lclResult->rowCount() > 0){
    while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
    # code...
    $lclUserName = $row['us_business_name'];
    $lclImage1 = $row['us_image1'];
    $lclCategory = $row['us_category'];
    $lclArea = $row['us_area'];
    ?>
        <div class="col-sm-4">
          <div class="card">
            <img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
            <div class="card-body">
              <h4 class="card-title">
                <?php echo $lclUserName?>
              </h4>
              <p class="card-text" style="font-size: 25px;">
                <?php echo $lclCategory?>
              </p>
              <hr>
              <i class="fa fa-map-marker" style="font-size: 23px;">
                <span>&nbsp;&nbsp;
                </span>
                <?php echo $lclArea?>
              </i>
              <!-- <a href="#" class="btn btn-primary">See Profile</a> -->
            </div>
          </div>
        </div>
        <?php
    }
    ?>
        <?php
    } else { 
    ?>
        <div class="container">
          <div class="row">
            <div class="col-sm-12">
              <h1> NO RESULT FOUND...
              </h1>
            </div>
          </div>
        </div>
        <?php
    }
    ?>
      </div>  
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?