Results 1 to 2 of 2

Thread: php delete images..

Hybrid View

  1. #1
    Join Date
    Aug 2006

    php delete images..

    hi, I'm kind of confused and rookie about the delete image file name from database, I have five images file name in database and store image file in the folder, each table column name is (image_1, image_2, images_3, image_4, image_5).

    In html , each image have delete button under bottom of image for up to five images.

    Let say that I want to delete 'image_3" by pressing button, how can i write that code to make sure that i can delete that images file name ONLY from database instead of delete rest of row!

    i wrote code but not sure working right...

    HTML Code:
    <a href='inventory_list.php?deleteid=$id'>delete</a>
    PHP Code:

    if (isset($_GET['yesdelete_image_3'])) {
    // remove item from system and delete its picture
        // delete from database
    $id_to_delete $_GET['yesdelete'];
    $sql mysql_query("DELETE FROM products WHERE id='$id_to_delete' LIMIT 1") or die (mysql_error());
    // unlink the image from server
        // Remove The Pic -------------------------------------------
    $pictodelete = ("../inventory_images/$id_to_delete.jpg");
        if (
    file_exists($pictodelete)) {
    header("location: inventory_list.php"); 

  2. #2
    Join Date
    Aug 2004
    Sounds like maybe you want to do an update query, not a delete?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center