0

我正在尝试从 php 中的 MYSQL 数据库中删除某个选定的值。

[删除.php]

<form name="delete" method="POST" action="d3l3t3d.php">
    <select name="eBox" id="nname" style="width: 290px; height:40px;">
    <?php
    mysql_connect("a","b","") or die("Wrong username or password");
    mysql_select_db("TABLE") or die( "Unable to select database");
    $query = "Select * From list";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) 
    { 
    $name = $row['name']; 
    echo "<option>" . $name . "</option>"; 
    } 
    echo "</select><br/><br/>"
    ?>

[d3l3t3d.php]

<?php
   $namez = $_POST['nname'];
   $name = mysql_real_escape_string($namez);
   mysql_connect("a","b",
   "") or die("Wrong username or password");
   mysql_select_db("TABLE") or die( "Unable to select database");
mysql_query("DELETE FROM list WHERE name='$name'");
?>

我收到以下错误:

注意:未定义索引:第 2 行 C:\xampp\htdocs\folder\d3l3t3d.php 中的 nname

4

2 回答 2

1

$namez = $_POST['nname'];应该$namez = $_POST['ebox'];

您可以通过名称而不是 id 选择元素。

于 2013-04-07T02:53:23.317 回答
0

$namez = $_POST['nname'];应该$namez = $_POST['eBox'];

错误: Undefined index: nname in C:\xampp\htdocs\folder\d3l3t3d.php on line 2, 表示它正在搜索具有属性的元素name = "nname",当然,它不存在。你有name = "eBox"

只是一个小错字:)

于 2013-04-07T02:54:02.490 回答