SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    0 Post(s)
    0 Thread(s)

    Getting confirmation message before deleting data in php?

    Dear All

    I am using below script for deleting data from data base & its working fine.

    I just want to add a feature in it & that is, just to show a confirmation message before deleting the data.

    Is it possible???

    Kindly help.
    <tr bgcolor="#FDEEF4">
    <th><span class="preppy2">#</span></th>
    <th><span class="preppy2">ID</span></th>
    <th><span class="preppy2">COL NAME</span></th>
    <th><span class="preppy2">SHADE &#37;</span></th>
    <th><span class="preppy2">LAB SUB NO</span></th>
    <th><span class="preppy2">LAB SUB DATE</span></th>
    <th><span class="preppy2">LAB REF NO#</span></th>
    <th><span class="preppy2">APVD SHADE</span></th>
    <th><span class="preppy2">DYEING FACT</span></th>
    <th><span class="preppy2">USE AT</span></th>
    <th><span class="preppy2">BOOKING REF</span></th>
    <th><span class="preppy2">REMARKS</span></th>
    <tr align="center">
      <td><input name="need_delete[<?php echo $rows['tbl_color_id']; ?>]" type="checkbox" id="checkbox[<?php echo $rows['tbl_color_id']; ?>]" value="<?php echo $rows['tbl_color_id']; ?>"></td>
        <td><span class="preppy3"><?php echo $rows['tbl_color_id']; ?></span></td>
          <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_color_name']); ?></span></td>
            <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_shade_percent']); ?></span></td>
             <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_ld_sub_no']); ?></span></td>
                <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_ld_sub_date']); ?></span></td>
                <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_ld_ref']); ?></span></td>
                <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_ld_shade']); ?></span></td>
                  <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_dying']); ?></span></td>
                    <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_fab_bkng_ref']); ?></span></td>
                     <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_useat']); ?></span></td>
                       <td><span class="preppy3"><?php echo htmlspecialchars($rows['col_color_rmks']); ?></span></td>
               <tr align="center" bgcolor="#FD9003">  
    <td colspan="12" bgcolor="#FFE4E1">   </td>  
           <tr align="center" bgcolor="#FD9003">  
            <td colspan="12" bgcolor="#A6B39D">&nbsp;</td>  
    <tr align="center" bgcolor="#FD9003">  
    <td colspan="12" bgcolor="#FFE4E1">   </td>  
                    <td colspan="12" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>
                    // Check if delete button active, start this
                    if ( ! empty($_POST['delete'])) {
                        foreach ($_POST['need_delete'] as $tbl_color_id => $value) {
                            $sql = 'DELETE FROM `'.$tbl_name.'` WHERE `tbl_color_id`='.(int)$tbl_color_id;
                            print $sql;
                            $result = mysql_query($sql);}
                           // mysql_query($sql);

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    France, deep rural.
    17 Post(s)
    1 Thread(s)
    I usually do that using Javascript, its much slicker, less code and less prone to error.

    If user does not have JS turned on, just delete anyway -- how much of an edge case is that going to be?


Posting Permissions

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