i have a row in the table 'files' where 'id' is a unique identifier column, and equals $imgId. imgId=$row['id'];
<script type="text/javascript">
$( "#<?php echo $imgId ?>" ).click(function() {
<?php
$sql = "DELETE FROM files WHERE id=$imgId";
if ($con->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $con->error;
}
$conn->close();
?>
});
</script>
I am displaying multiple embeds where the html id is equal to the unique identifier sql column id for that image.
<embed id="<?php echo $imgId; ?>"class="delete-row" src="<?php echo $filePath; ?>" type="<?php echo $fileMime; ?>"/>
I just want it so when you click on a spcific image it deletes it from the database and removed the image file from the /uploads folder. Any help would be awesome.