title: PHP - foreach loop in mysql row
body: <p>I am trying to generate dynamic images, I am using jquery to pass the <code>id</code> of the image from the mysql db to produce dynamic result , but it doesn't seems to working it only printing one image , my code is here</p>
  
  <pre><code> &lt;?php
  
   include 'conn.php';
  
   if (mysqli_connect_errno()) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();
  }
  
   $query = "SELECT id FROM homebg";
   $result = mysqli_query($conn, $query);
   if ($result-&gt;num_rows &gt; 0) {
  
   while($row = $result-&gt;fetch_assoc()) {
   foreach ($row as $value) {
          echo " 
          &lt;img class=\"responsive-img col l3\" id=\"img\"&gt;
          &lt;script&gt;  
  $('#img').attr(\"src\",\"getImageadmin.php?id=\"+".$value.");
  $('#img').show();
  &lt;/script&gt; ";
      }
    }
  }
  mysqli_close($conn);
  ?&gt;  
  </code></pre>
  
  <p>Here I want to pass the value(<code>id</code>) of the image to the jquery used one by one , in each iteration so that it can print images one by one next to each other  </p>