title: Can't show an image before uploading
body: <p>This is my problem when im trying to change the image to my 2nd data it's not changing but when i tried the first data it's changing i don't know the reason why it's not working on the second data. Can someone help me with this?</p>
  
  <p>Here is my form where the image and file is in.</p>
  
  <p><strong>Update</strong>
  here is the picture the news with id 42 when i change the image of that the image is not changing but with the news with id 40 it's changing. </p>
  
  <p><a href="https://i.stack.imgur.com/JOr9U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JOr9U.png" alt="enter image description here"></a>
  Here is my whole code.
       
  
  <pre><code>  $stmt = mysqli_prepare($con, "SELECT * FROM news ORDER BY news_id");
    mysqli_stmt_execute($stmt);
    $result = mysqli_stmt_get_result($stmt);
    while($row = mysqli_fetch_array($result)){
    ?&gt;
     &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $row['news_id']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['news_title']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['news_date']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo $row['news_content']; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;img style="height:150px; width:200px;" src="&lt;?php echo $row['news_image']; ?&gt;"  &gt;&lt;/td&gt;
    &lt;td&gt;
  
    &lt;button class="btn btn-info" data-toggle="modal" data-target="#newsedit&lt;?php echo $row['news_id'];?&gt;"&gt;&lt;span class="glyphicon glyphicon-edit"&gt;&lt;/span&gt;  Edit&lt;/button&gt;
    &lt;a class='btn btn-danger delete-object' data-toggle="modal" data-target="#newsdelete&lt;?php echo $row['news_id'];?&gt;"&gt;&lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt; Delete&lt;/a&gt;
  
    &lt;div class="modal fade" id="newsdelete&lt;?php echo $row['news_id'];?&gt;" role="dialog" aria-labelledby="myModalLabel"&gt;
        &lt;div class="modal-dialog" role="document"&gt;
                &lt;div class="modal-content"&gt;
                      &lt;div class="modal-body"&gt;
                         Are you sure you want to delete this?
                              &lt;/div&gt;
       &lt;div class="modal-footer"&gt;
        &lt;a class='btn btn-danger left-margin' href="delete.php?newsid=&lt;?php echo $row['news_id'];?&gt;" &gt;Yes&lt;/a&gt;
      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;No&lt;/button&gt;
            &lt;/div&gt;
             &lt;/div&gt;
            &lt;/div&gt;
            &lt;/div&gt;
  
       &lt;div id="newsedit&lt;?php echo $row['news_id'];?&gt;" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
               &lt;div class="modal-dialog"&gt;
                   &lt;div class="modal-content"&gt; 
                          &lt;div class="modal-header"&gt;
                                       &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
                                      &lt;h4 class="modal-title" id="myModalLabel"&gt;Edit events&lt;/h4&gt;
                                    &lt;/div&gt;
  
                                   &lt;div class="modal-body edit-content"&gt;
                                      &lt;form method="POST" enctype="multipart/form-data" action ="edit2.php?newsid=&lt;?=$row['news_id']?&gt;"&gt;
                                            &lt;div class="form-group"&gt;
                                              &lt;label for="title"&gt;News Title&lt;/label&gt;
                                              &lt;input type="text" name="titles" class="form-control title" id="title" placeholder="News Title" value="&lt;?php echo $row['news_title']; ?&gt;"&gt;
                                            &lt;/div&gt;
  
                                            &lt;div class="form-group"&gt;
                                               &lt;label for="date"&gt;Date&lt;/label&gt;
                                               &lt;input type="text" name="dates" class="form-control date" id="date" placeholder="Date" value="&lt;?php echo $row['news_date']; ?&gt;"s&gt;
                                           &lt;/div&gt;
  
                                           &lt;div class="form-group"&gt;
                                              &lt;label for="content"&gt;News Content&lt;/label&gt;
                                              &lt;textarea class="form-control content" name="contents" rows="5" id="content"&gt;&lt;?php echo $row['news_content']; ?&gt;&lt;/textarea&gt;
                                           &lt;/div&gt;
  
  
                                           &lt;img id="blah" name="newsimages" src="&lt;?php echo $row['news_image']; ?&gt;" width="200px" height="140px"/&gt;
                                              &lt;input id="image" name="image" class="fileupload" type="file" accept="image/*"/&gt;
  
                                   &lt;/div&gt;
  
                                 &lt;div class="modal-footer"&gt;
                                  &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                                  &lt;button type="submit" class='btn btn-info left-margin'&gt;Yes&lt;/a&gt;
                                    &lt;/form&gt;
                              &lt;/div&gt;
                                &lt;/div&gt;
                          &lt;/div&gt;
                     &lt;/div&gt;
  
  
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;?php
          }
          ?&gt;
  </code></pre>
  
  <p>here is the js for showing the image before uploading.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function readURL(input) {
          if (input.files &amp;&amp; input.files[0]) {
              var reader = new FileReader();
  
              reader.onload = function (e) {
                  $('#blah').attr('src', e.target.result);
              }
  
              reader.readAsDataURL(input.files[0]);
          }
      }
  
      $("#image").change(function(){
          readURL(this);
      });
      &lt;/script&gt;
  </code></pre>