1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP delete script

Discussion in 'PHP' started by dean5000v, Jul 23, 2008.

  1. #1
    ok well ive basically takes takes the table name and id from the user and then delets it from the database here is my part of the script.

    <?php
    $delete_item_code = mysql_escape_string($_POST['delete_item_code']);
    if(isset($_POST['Delete'])) {
    if (!isset($_POST['delete_item_code']) || trim($_POST['delete_item_code']) == "" ) {
        echo "<span class=\"red\">Please enter a stock code</span>";
    }
    else if(empty($deletetable))
    {
    echo "<span class=\"red\">Please Select a Table</span>";
    }
    else {
    		 $sqlquery="DELETE FROM `$deletetable` WHERE item_code = $delete_item_code ";
    		 $resultdelete=mysql_query($sqlquery);
    echo mysql_error();
    echo "<div id=\"added\"><span class=\"font\">Your stock item $item_code has been Deleted</span></div>"; 
    
    }
    }
    ?>
    Code (markup):

    However if it doesn't delete a item for example the item number doesn't exist it doesnt give me a warning does anyone know any ways i can give the usr a warning if the id doesn't exit within the table.
     
    dean5000v, Jul 23, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Jul 23, 2008 IP