html - php unlink a div or place div in variable -


ok, bottom line is. i've got image gallery on website. can upload , retrieve images mysqli database. multiple images placed placeholder divs, shows little box around image , name of image. i've got delete function per image works php unlink. whenever delete image, box , name of image still appear.

is there way not unlink image, entire div placeholder delete entirely? or, there way place div inside variable, because know how unlink variable containing multiple fles. here code

the div called "media".

    <ul class="media-list">       <?php       include "config.php"; //database connection       $res = $mysqli->query("select * upload_data");       while ($row = $res->fetch_assoc()):       ?>      <div class="media">         <a class="media-left" href="#">    <!--  <img src="upload/<?php echo $row['file_name'] ?>" alt="<?php echo $row['file_name'] ?>"> -->    </a>         <div class="img"><?php if (isset($_session['email']))               {         echo '<a href="delete.php?id=&nm=<?php echo $row[\'file_name\'] ?>">delete</a>';} ?>    <a target="_blank" href="javascript:popimage('upload/<?php echo $row['file_name'] ?>','<?php echo $row['file_name'] ?>')">     <img width="300" height="200" src="upload/<?php echo $row['file_name'] ?>" alt="<?php echo $row['file_name'] ?>">             </a>           </div>         </div>      <?php       endwhile;       ?> 

here's unlink code if you're wondering:

<?php include "config.php";   if(isset($_get['id'])):   $hap = unlink('upload/'.$_get['nm']);   if($hap){      $stmt = $mysqli->prepare("delete upload_data id_upload=?");      $stmt->bind_param('s', $id);       $id = $_get['id'];       if($stmt->execute()):           echo "<script>location.href='gallery.php'</script>";      else:           echo "<script>alert('".$stmt->error."')</script>";      endif;   } else{     echo "<script>alert('no delete file harddisk')</script>";     echo "<script>location.href='gallery.php'</script>";   } endif; ?> 

the file deleted correctly.

but you're passing wrong parameter sql query. $id not defined on line $stmt->bind_param('s', $id);

supposing id_upload column integer. replace line this:

$stmt->bind_param('i', (int)$_get['id']); 

Comments