我有以下代码从我的数据库中检索项目并将它们显示在表格中。该文件是manage-products.php。
while($row = mysql_fetch_row($result)){
echo '</tr>';
echo ' <td class="product"><a href="manage-products-2.php">'.$row[1].'</a></td>';
echo'<td class="quantity">'.$row[5].'</td>';
echo '<td class="item_price">'.$row[4].'</td>';
echo '<td class="item_total">'.$row[6].'</td>';
echo '<td class="item_unsold"><a href = "manage-products.php?prod = '.$row[0].'" style="color:red">Delete</a></td>';//to delete an item
echo '</tr>';
}
单击删除链接时(也在manage-products.php中),我有以下代码(应该执行)
$prodid = $_GET['prod'];
if($prodid != ""){
echo '<script type="text/javascript">
var r = window.confirm("Are you sure you want to delete this product") ;
if(r == true){
$ . post ( "manage-products.php" , { result : r });
}
</script>';
$delete = $_POST['result'];
if($delete == true){
$SQL1 = "DELETE FROM tbl_product WHERE id = '$prodid'";
$result1 = mysql_query($SQL1);
}
}
当我单击删除时,它显示未定义的索引:产品。请问我的错误在哪里。谢谢