www.webdeveloper.com
Results 1 to 2 of 2

Thread: Delete with confirmation

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Posts
    57

    Delete with confirmation

    Hi, I'm having trouble to understand how this works, I have five images that store images file name in mysql, each images comes with delete button.

    so let say that second remove image button called

    PHP Code:
     <input name="remove_images_2" type="submit" /> 
    and 3rd images remove button called

    PHP Code:
     <input name="remove_images_3" type="submit" /> 
    and in call sql to remove image file name from database
    PHP Code:
    <?php 
    // Remove image_2 from database
        
    if (isset($_POST['remove_images_2'])){
        
        
    $sql mysql_query("UPDATE product SET images_2='NULL' where product_id='$targetID' LIMIT 1");
        }
    else
    // Remove image_3 from database
        
    if (isset($_POST['remove_images_3'])){
        
    $sql mysql_query("UPDATE product SET images_3='NULL' where product_id='$targetID' LIMIT 1");
        }
    else
    // Remove image_4 from database
        
    if (isset($_POST['remove_images_4'])){
        
    $sql mysql_query("UPDATE product SET images_4='NULL' where product_id='$targetID' LIMIT 1");
        }
    else
    // Remove image_5 from database
        
    if (isset($_POST['remove_images_5'])){
        
    $sql mysql_query("UPDATE product SET images_5='NULL' where product_id='$targetID' LIMIT 1");
        }
    ?>
    My question is how to write code to popup confirmation code to say "are you sure you want to delete this images! with (yes and no buttons)"

    Dose anyone can help me how to write that code i know is sound easy but because i'm rookie in php.. please help thanks.

    AM

  2. #2
    Join Date
    Dec 2013
    Posts
    63
    My question is how to write code to popup confirmation code to say "are you sure you want to delete this images! with (yes and no buttons)"
    Do you mean confirmation dialog in javascript? If so you can add
    Code:
    onsubmit="return confirm('Do you really want to delete this image?');"
    to 'form' tag.
    This is only one line of code and it will work without reloading the page but it will not work if the user have javascript disabled in his browser of course.

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