lufofola
Intel Collector
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
PHP Deleting Image In MySQL
In this tutorial, we are going to discuss PHP Deleting Image In MySQL. We're gonna use Delete Statement to delete an image from our database table. This will be easy if you read or follow our previous tutorial in PHP Insert Image In MySQL.
"tbl_image" Example Database Table.
Our Data
Deleting Image In MySQL Using PDO
Deleting image in our "tbl_image" table.
Form Field - Modal Form
DELETE Statement
Output:
Deleting image.
After deleting the image.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
In this tutorial, we are going to discuss PHP Deleting Image In MySQL. We're gonna use Delete Statement to delete an image from our database table. This will be easy if you read or follow our previous tutorial in PHP Insert Image In MySQL.
"tbl_image" Example Database Table.
Our Data

Deleting Image In MySQL Using PDO
Deleting image in our "tbl_image" table.
Form Field - Modal Form
- <!-- Modal -->
- <div
id
=
"delete<?php echo $id;?>
" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
- <div
class
=
"modal-header"
>
- <h3
id
=
"myModalLabel"
>
Delete</
h3
>
- </
div
>
- <div
class
=
"modal-body"
>
- <div
class
=
"alert alert-danger"
>
- <?php if(
$row[
'image_location'
]
!=
""
)
: ?>
- <img
src
=
"uploads/<?php echo $row['image_location']; ?>
" width="100px" height="100px" style="border:1px solid #333333;">
- <?php else: ?>
- <img
src
=
"images/default.png"
width
=
"100px"
height
=
"100px"
style
=
"border:1px solid #333333; margin-left:15px;"
>
- <?php endif; ?>
- <b
style
=
"color:blue; margin-left:25px; font-size:30px;"
><?php echo $row[
'first_name'
]
." "
.$row[
'last_name'
]
; ?></
b
>
- <br
/
>
- <p
style
=
"font-size: larger; text-align: center;"
>
Are you Sure you want to Delete?</
p
>
- </
div
>
- <hr
>
- <div
class
=
"modal-footer"
>
- <button
class
=
"btn btn-inverse"
data-dismiss=
"modal"
aria-hidden=
"true"
>
No</
button
>
- <a
href
=
"delete.php<?php echo '?tbl_image_id='.$id; ?>
" class="btn btn-danger">Yes</
a
>
- </
div
>
- </
div
>
- </
div
>
DELETE Statement
- <?php
- require_once
(
'db.php'
)
;
- $get_id
=
$_GET
[
'tbl_image_id'
]
;
- // sql to delete a record
- $sql
=
"Delete from tbl_image where tbl_image_id = '$get_id
'"
;
- // use exec() because no results are returned
- $conn
->
exec
(
$sql
)
;
- header
(
'location:index.php'
)
;
- ?>
Output:
Deleting image.

After deleting the image.

Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Download
You must upgrade your account or reply in the thread to view hidden text.