title: php unlink a div or place div in variable
body: <p>Ok, bottom line is. I've got an image gallery on my website. I can upload and retrieve images to my Mysqli database. The multiple images are placed into placeholder divs, which shows a little box around the image and the name of the image. I've got a Delete function per image that works with PHP unlink. But whenever I delete the image, the box and name of the image still appear. </p>
  
  <p>Is there a way to not just unlink the image, but the entire div so the placeholder will delete entirely? Or, is there a way to place a div inside a variable, because I know how to unlink a variable containing multiple fles. Here is my code </p>
  
  <p>The div is called "media". </p>
  
  <pre><code>    &lt;ul class="media-list"&gt;
        &lt;?php
        include "config.php"; //database connection
        $res = $mysqli-&gt;query("SELECT * FROM upload_data");
        while ($row = $res-&gt;fetch_assoc()):
        ?&gt; 
      &lt;div class="media"&gt;    
  
     &lt;a class="media-left" href="#"&gt;
     &lt;!--  &lt;img src="upload/&lt;?php echo $row['file_name'] ?&gt;" alt="&lt;?php echo $row['file_name'] ?&gt;"&gt; --&gt;
     &lt;/a&gt;
          &lt;div class="img"&gt;&lt;?php if (isset($_SESSION['email'])) 
  
              {
          echo '&lt;a href="delete.php?id=&amp;nm=&lt;?php echo $row[\'file_name\'] ?&gt;"&gt;Delete&lt;/a&gt;';} ?&gt;
  
    &lt;a target="_blank" href="javascript:popImage('upload/&lt;?php echo $row['file_name'] ?&gt;','&lt;?php echo $row['file_name'] ?&gt;')"&gt;
      &lt;img width="300" height="200" src="upload/&lt;?php echo $row['file_name'] ?&gt;" alt="&lt;?php echo $row['file_name'] ?&gt;"&gt;
              &lt;/a&gt;  
          &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;?php
        endwhile;
        ?&gt;
  </code></pre>
  
  <p>Here's also the unlink code if you're wondering: </p>
  
  <pre><code>&lt;?php
  include "config.php";
  
  
  if(isset($_GET['id'])):
    $hap = unlink('upload/'.$_GET['nm']);
    if($hap){
       $stmt = $mysqli-&gt;prepare("DELETE FROM upload_data WHERE id_upload=?");
       $stmt-&gt;bind_param('s', $id);
  
       $id = $_GET['id'];
  
       if($stmt-&gt;execute()):
            echo "&lt;script&gt;location.href='gallery.php'&lt;/script&gt;";
       else:
            echo "&lt;script&gt;alert('".$stmt-&gt;error."')&lt;/script&gt;";
       endif;
    } else{
      echo "&lt;script&gt;alert('No Delete File From Harddisk')&lt;/script&gt;";
      echo "&lt;script&gt;location.href='gallery.php'&lt;/script&gt;";
    }
  endif;
  ?&gt;
  </code></pre>