0

This is my code

    echo"<tr>";
        echo "<td>". $row["item_name"]."</td>";
        echo "<td>". $row["description"]."</td>";
        echo '<td><img class="avatar" src="'.$row["imglink"].'"></td>';
        echo "<td>". $row["status"]."</td>";
        echo '<td><a href="studentinventoryedit.php?item_id='.$row['item_id'].'"><button title="edit" type="button" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-pencil white"></span></button></a>
        <a href="deleteitem.php?item_id=' . $row["item_id"].'";><button name="delete" type="button"  class="btn btn-default btn-sr"  data-confirm="Are you sure to delete this item?"><span class="glyphicon glyphicon-trash white"></span></button></a>';

my php code

<?php
session_start();
require 'dbconfig/config.php';
$item_id = $_GET['item_id']; // $id is now defined
$query = "DELETE  from itemtbl where item_id='$item_id'";
$query_run = mysqli_query($con,$query);
$path = $_POST['imglink'];
            header("Location: studentinventory.php?"); //redirect to relevant page
?>

here is a picture of my database: database

if i click delete it will pass id, and delete the item file, but the image is not being deleted.I tried to google on how to delete image from folder but fail to do so.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
KingJ
  • 113
  • 1
  • 7

0 Answers0