www.webdeveloper.com
Results 1 to 2 of 2

Thread: php delete images..

  1. #1
    Join Date
    Aug 2006
    Posts
    57

    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...
    button

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


    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)) {
                       
    unlink($pictodelete);
        }
        
    header("location: inventory_list.php"); 
        exit();
    }
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,518
    Sounds like maybe you want to do an update query, not a delete?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles