<?php include_once 'connection/conn.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="10">
<tr>
<th>
Name
</th>
<th>
Email
</th>
<th>
Address
</th>
</tr>
<?php
// $query = "SELECT name, address FROM user";
$query = "SELECT * FROM user";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr>
<td>
<?= $row['name'] ?>
</td>
<td>
<?= $row['email'] ?>
</td>
<td>
<?= $row['address'] ?>
</td>
</tr>
<?php
}
} else {
echo "no record found";
}
?>
</table>
</body>
</html>
Delete.php
<?php include_once 'connection/conn.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="">
<label for="">Insert id</label>
<input type="text " name="userId">
<input type="submit" name="submit">
</form>
<?php
if (isset($_REQUEST['submit'])) {
$id = $_REQUEST['userId'];
$query = "DELETE FROM user WHERE name = '$id'";
$result = mysqli_query($conn, $query);
if ($result) {
echo "data Deleted";
} else {
echo "Error";
}
}
?>
</body>
</html>
Comments
Post a Comment