php - Making Photo Grid with Different size images -


ok, may simple. but, can't figure out how it. want query 1 table , show results in 2 divs on page. mean have html this:

<div class="row">     <div class="small">       //     </div>     <div class="large">       //     </div>     <div class="small">       //     </div>     <div class="small">       //     </div>     <div class="small">       //     </div>     <div class="large">       //     </div> </div> 

and query this

$stmt = $pdo->prepare("select * cars cars_cat = ? order car_id desc"); $stmt->execute(array($cat_id)); $data = $stmt->fetchall();  foreach($data $row)  {  } 

the database table simple table id, name, image, cars_cat.

update: structure of gallery

  <div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- first column -->         <div class="small">         </div>           <div class="large">         </div>           <div class="small">         </div>         <div class="small">         </div>   </div> <!-- end first column -->   <div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- second column -->        <div class="small">         </div>         <div class="small">         </div>         <div class="large">         </div>         <div class="small">         </div>   </div> <!-- end second column -->   <div class="col-sm-4 col-md-4 col-lg-4 nopadding"> <!-- third column -->         <div class="large">         </div>         <div class="small">         </div>         <div class="large">             //        </div>    </div> <!-- end third column --> 

try way

<style>     .row {         -webkit-column-width:400px;         -moz-column-width:400px;         column-width:400px;         -webkit-column-gap:5px;         -moz-column-gap:5px;         column-gap:5px;     }     .small-box{         display:inline-block;          margin:0 0 5px 0;         padding:10px;         color:white;     }     .img-responsive{       width:100%;       height:auto;     } </style>          <div class="row">                 <div class="small-box">                     <img src="http://aneemals.com/wp-content/uploads/2013/04/photos-of-animals-that-know-what-love-is-3.jpg" alt="img" class="img-responsive">                 </div>                 <div class="small-box">                     <img src="http://www.softstuffcreations.com/refresh/data/zoom_image/1772-pandabear_resized.jpg" alt="img" class="img-responsive">                 </div>                  <div class="small-box">                     <img src="http://images6.fanpop.com/image/photos/35600000/wild-animals-animals-of-the-world-35665506-800-533.jpg" alt="img" class="img-responsive">                 </div>                 <div class="small-box">                     <img src="http://nice-animals.com/wp-content/uploads/2013/10/facts-of-love-between-animals-08.jpg" alt="img" class="img-responsive">                 </div>                 <div class="small-box">                     <img src="http://www.kenya.com/wp-content/uploads/2013/03/mt-kenya-animals.jpg" alt="img" class="img-responsive">                 </div>                 <div class="small-box">                     <img src="http://www.softstuffcreations.com/refresh/data/zoom_image/1772-pandabear_resized.jpg" alt="img" class="img-responsive">                 </div>                 <div class="small-box">                     <img src="http://fc09.deviantart.net/fs71/i/2012/364/4/3/animals___lion_9_by_moonsongstock-d5pr9za.jpg" alt="img" class="img-responsive">                 </div>         </div> 

means need update update code way

    <div class="row">    <?php       foreach($data $row)  {              echo '<div class="small-box"> image </div>';           } ?> </div> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -