while($row=mysqli_fetch_assoc($result)){
echo "<tr>";
echo ('<td>'.$row['idNo'].'</td>');
echo ('<td>'.$row['FirstName'].'</td>');
echo ('<td>'.$row['LogId'].'</td>');
echo ('<td>'.$row['PassCode'].'</td>');
echo '<td><a href="edit.php?id=' . $row['idNo'] . '">Edit</a></td>';
echo '<td><a href="delete_contestant.php?id=' . $row['idNo'] . '">Delete</a></td>';
echo("</tr>");}
delete_contestant.php
页面的代码如下。但是当我试图删除一个项目时
显示未定义的索引:第3行中的idNo
即使我正在尝试打印$_GET['idNo']
,但它无效。
<?php
include('mysql_connect.php');
echo $_GET['idNo'];
if(isset($_GET['idNo']))
{
$id=$_GET['idNo'];
$sql="DELETE FROM addContestant WHERE idNo=$id";
if(mysqli_query($conn,$sql))
{
echo "Item deleted";
}
else
echo "There was a problem".mysqli_error($conn);
}
?>
答案 0 :(得分:2)
您没有名为GET
的{{1}}参数,它的ID
idNo
将您的代码更改为
echo '<td><a href="edit.php?id=' /* <<<< id, not idNo */. $row['idNo'] . '">Edit</a></td>';
它应该有用。