-1

我想知道为什么这段代码不起作用?该按钮执行正确的确认序列,但实际上并未删除记录。我从一个工作按钮复制并粘贴了代码,我认为在传输中我错过了指定细节?

if (isset($_GET['deleteseries'])) {
    echo 'Do you really want to delete ' 
        . $_GET['series'] 
        . '? <a  href="editstock.php?yesdelete=' 
        . $_GET['id'] 
        . '">Yes</a> | <a href="editstock.php">No</a>';
    exit();
}

if (isset($_GET['yesdelete'])) {
    $deleteSQL = sprintf("DELETE FROM series WHERE id='%s' LIMIT 1",
        GetSQLValueString($_GET['yesdelete'], "int"));

    mysql_select_db($database_connectmysql, $connectmysql);
    $Result1 = mysql_query($deleteSQL, $connectmysql) or die(mysql_error());
    header("location: editstock.php"); 
    exit();
}

使用此按钮:

<input name="deleteseries" 
    type="button" id="deleteseries" 
    value="delete" 
    style="width:20%; float:right" 
    onclick="window.location.href = '?deleteseries=delete&id=<?php echo $row_seriesrecordset['id']; ?>&series=<?php echo $row_seriesrecordset['series']; ?>'"/>
4

2 回答 2

0

尝试这个:

if (isset($_GET['yesdelete'])) {
    $deleteSQL = sprintf("DELETE FROM series WHERE id='%s' LIMIT 1",
        GetSQLValueString($_GET['yesdelete'], "int"));

    mysql_select_db($database_connectmysql, $connectmysql);
    $Result1 = mysql_query($deleteSQL, $connectmysql) or die(mysql_error());
    echo "deleted entry with ID ".$_GET['yesdelete'];
    exit;
    header("location: editstock.php"); 
    exit();
}

它说什么条目被删除了?也许您传递了错误的“yesdelete”参数(错误的 ID)..

于 2013-07-11T05:59:18.520 回答
-2

一切都是正确的,只是您在以下代码中犯了一个小错误:

if (isset($_GET['yesdelete'])) {
    $deleteSQL = sprintf("DELETE FROM series WHERE id='. $_GET['yesdelete'] LIMIT 1",
        GetSQLValueString($_GET['yesdelete'], "int"));

    mysql_select_db($database_connectmysql, $connectmysql);
    $Result1 = mysql_query($deleteSQL, $connectmysql) or die(mysql_error());
    header("location: editstock.php"); 
    exit();
}
于 2013-07-11T05:50:17.403 回答