How to delete image form folder and database

0 votes

With the code below, I'm displaying data from a MySQL database in a Table.

<td><?php echo $row['name']; ?></td>
			<td><?php echo $row['image']; ?></td>
			<a title="Delete" href="deletestudent.php?id=<?php echo $row['id']; ?>"><button class="btn btn-danger btn-mini"> Delete</button></a></td>

The first row displays the picture name, while the second row displays the image that is located inside the images directory.
I can delete the row using the code below:

<?php
	include('../connect.php');
	$id=$_GET['id'];
	$result = $db->prepare("DELETE FROM student WHERE id= :memid");
	$result->bindParam(':memid', $id);
	$result->execute();
	
	header ("location: students.php");
?>

But I also want to remove one image from the Images folder. How can I do that?

Jul 26 in PHP by Kithuzzz
• 4,480 points
16 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

How to upload image and save path to database?

I have a page with some displayed ...READ MORE

Jul 22 in PHP by Kithuzzz
• 4,480 points
14 views
0 votes
1 answer

How to validate E-mail and URL of Php form?

hey, The code below shows a simple way ...READ MORE

answered Feb 13, 2020 in PHP by manish
1,172 views
0 votes
1 answer

How to delete all files from a folder using PHP?

Hello @kartik, Use this: $files = glob('path/to/temp/*'); // get ...READ MORE

answered Sep 14, 2020 in PHP by Niroj
• 82,740 points
279 views
0 votes
1 answer

How to upload and delete files from dropzone.js?

Hello, For deleting thumbnails you have to enable ...READ MORE

answered Nov 4, 2020 in PHP by Niroj
• 82,740 points
5,711 views
0 votes
0 answers

How to display image from database using PHP?

I want to display an image from ...READ MORE

May 11 in PHP by Kichu
• 19,040 points
24 views
0 votes
0 answers

How to retrieve images from MySQL database and display in an html tag

I created a table using the  BLOB column ...READ MORE

Jun 19 in PHP by narikkadan
• 11,280 points
64 views
0 votes
1 answer
0 votes
0 answers
0 votes
0 answers

Creating a search form in PHP [duplicate]

I am working on a function where ...READ MORE

Jun 9 in PHP by Kichu
• 19,040 points
15 views
0 votes
0 answers

How to retrieve data from multiple tables using a PHP form?

I want to retrieve data from multiple ...READ MORE

Jun 25 in PHP by narikkadan
• 11,280 points
21 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP