首页 >社区问答列表 >显示这行if (is_array($_POST['id'])) 未定义索引id;

显示这行if (is_array($_POST['id'])) 未定义索引id;

delete.php:
<?php
include_once("conn\conn.php");
if (is_array($_POST['id'])) {
    $id = join(',', $_POST['id']);
} elseif (is_numeric($_GET['id'])) {
  
  $id = (int) $_GET['id'];
} else {
    echo '数据不合法';
    exit;
} $sql = "delete from padd where id in($id)";
$result = mysqli_query($connID, $sql);
if ($result) {
    echo '删除成功';
} else {
    echo '删除失败';
}
?>

index.php如下:
<?php

include_once("conn\conn.php");
$sql = "select * from padd order by id desc";
$result = mysqli_query($connID, $sql);
if ($result && mysqli_num_rows($result)) {
echo '<form action="delete.php" method="post">';
    echo '<table width="800" border="1">';
    while ($row = mysqli_fetch_assoc($result)) {
        echo '<tr>';
        echo '<td><input type="checkbox" name="id[]" value="' . $row['id'] . '" /></td>';
        echo '<td>' . $row['name'] . '</td>';
        echo '<td>' . long2ip($row['pad']) . '</td>';
        echo '<td><a data-href="edit.php?id=' . $row['id'] . '">编辑用户</a></td>';
        echo '<td><a data-href="delete.php?id=' . $row['id'] . '">删除用户</a></td>';
        echo '</tr>';
    }
    echo '</table>';
    echo '<input type="submit" value="删除" />';
    echo '</form>';
} else {
 echo '没有数据';
}

mysqli_close($connID);

?>
J1NG`{YL6J1@JJBWS9GU}PT.png

无数据提示还没有回复,楼主喊你快去抢前排~~~我来回答