Display this line if (is_array($_POST['id'])) Undefined index id;
1分之二
1分之二 2018-02-14 15:34:52
0
0
2823

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 href="edit.php?id=' . $row['id'] . '">编辑用户</a></td>';
        echo '<td><a 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

1分之二
1分之二

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template