Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
1.24/5 (3 votes)
i want to display image with randomly selected or the one that i choose from database.
but i don't really know how to code it properly.

What I have tried:

PHP
$query1=mysqli_query($db_con,"select * from image_tb");
   while($row=mysqli_fetch_array($query1)){
   $img = "";
   $image_number = $row['id'];
   
   

<div class="block-content collapse in">
     <div class="row-fluid padd-bottom">
     <div class="span3">
//i want to display here the first image on my database but i don't how to code it properly. 
      <a href="#" class="thumbnail">
      if (1 == $image_number){
          <?php echo "$img"; ?>
      }
       </a>
       </div>
       <div class="span3">
//the 2nd image from database
      <a href="#" class="thumbnail">
      if (2 == $image_number){
          <?php echo "$img"; ?>
      }
      </a></div><a href="#" class="thumbnail">
       </a><div class="span3"><a href="#" class="thumbnail">
//3nd image 
      </a><a href="#" class="thumbnail">
      if (1 == $image_number){
          <?php echo "$img"; ?>
      }
       </a>
       </div>
<div class="span3">
//4th image 
      <a href="#" class="thumbnail">
      if (1 == $image_number){
          <?php echo "$img"; ?>
      }
       </a>
       </div>
     </div>
<?php
  }
?>
     </div>
Posted
Updated 4-Feb-18 5:10am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900