代码之家  ›  专栏  ›  技术社区  ›  javas

仅显示上载的php图像字段

  •  -1
  • javas  · 技术社区  · 7 年前

    我有3个像这样的图像场

    <?php echo $row['thumbnail1']; ?>
    <?php echo $row['thumbnail2']; ?>
    <?php echo $row['thumbnail3']; ?>
    

    如何显示

    如果只有图像1和2有数据。。

     <div class="col-xs-12">
        <a href="#"><img src="#" class="w-full"></a>
       </div>
    
    <!-- IF only 2 image available uploaded USE this -->                                                                        
    
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>
    
    <!-- IF only ALL/3 image available uploaded USE this -->        
    
    <div class="col-xs-4">
         <a href="#"><img src="#" class="w-full"></a>
     </div>
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>  
     <div class="col-xs-4">
           <a href="#"><img src="#" class="w-full"></a>
     </div>
    </div>
    

    dsa sdas

    1 回复  |  直到 7 年前
        1
  •  0
  •   Ajmal PraveeN    7 年前

    <?php
    if(isset($row['thumbnail1']))
    {
    ?>
     <div class="col-xs-12">
        <a href="#"><img src="#" class="w-full"></a>
       </div>
    <?php } ?>
    <!-- IF only 2 image available uploaded USE this -->                                                                        
    <?php
    if(isset($row['thumbnail2']))
    {
    ?>
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>
    <?php } ?>
    <!-- IF only ALL/3 image available uploaded USE this -->        
    <?php
    if(isset($row['thumbnail3']))
    {
    ?>
    <div class="col-xs-4">
         <a href="#"><img src="#" class="w-full"></a>
     </div>
     <div class="col-xs-4">
          <a href="#"><img src="#" class="w-full"></a>
     </div>  
     <div class="col-xs-4">
           <a href="#"><img src="#" class="w-full"></a>
     </div>
    <?php } ?>