title: how to change image from sql database during hover in php
body: <p><strong>PHP</strong>
  I am trying to change the image during hover. For hover I used jquery, but the problem is that the first image is showing from the SQL database but the image is not changing while I already saved the second image in database</p>
  <pre><code>&lt;?php 
  include('dbconnect.php');
  
          $sql = &quot;SELECT * FROM `products` JOIN `images` ON products.product_id=images.product_id&quot;;
  
          $res = mysqli_query($conn, $sql);
  
          echo &quot;&lt;/h3&gt; Total: &quot; . mysqli_num_rows($res) . &quot; Items Found &lt;/h3&gt;&quot;;
          ?&gt;
  
          &lt;br&gt;&lt;br&gt;
          &lt;div class=&quot;container&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
  
          &lt;?php
          while ($row = mysqli_fetch_assoc($res))  {
          ?&gt;      
              &lt;div class=&quot;col item_col&quot;&gt;
                  &lt;?php echo $row[&quot;img_id&quot;] . &quot;&lt;br&gt;&quot; . $row[&quot;product_id&quot;] .&quot;&lt;br&gt;&quot;. &quot;&lt;img src ='&quot;.$row[&quot;image_path1&quot;].&quot;' width=100px height=100px data-src1='&quot;.$row['image_path1'].&quot;' data-src2='&quot;.$row['image_path2'].&quot;'&gt;&quot;; ?&gt;
              &lt;/div&gt;  
          &lt;?php               
          }
          ?&gt;
  
          &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;?php
          include('dbclose.php');
          ?&gt;
  </code></pre>
  <p><strong>jquery</strong></p>
  <pre><code> &lt;script type=&quot;text/javascript&quot;&gt;
          $(document).ready(function () {
                   $(&quot;.imgs&quot;).each(function(i,el){               
                   $(this).mouseenter(function(){
                      $(this).attr(&quot;src&quot;,$(this).attr(&quot;data-src2&quot;))
                   }).mouseleave(function(){
                       $(this).attr(&quot;src&quot;,$(this).attr(&quot;data-src1&quot;))
                   })
              })
          
            });
   
        &lt;/script&gt;
  </code></pre>