-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
105 lines (75 loc) · 1.79 KB
/
delete.php
File metadata and controls
105 lines (75 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<title>Basic CRUD</title>
</head>
<body>
<?php
require 'config.php'; // include file connect to db
include 'menu.php'; //include menu list from menu.php, you may edit accordingly
$sql = "SELECT * FROM pelanggan";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row if record found
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Bapa</th>
</tr>";
while($row = $result->fetch_assoc()) {
echo "<tr>
<td> ". $row["idPelanggan"]. " </td>
<td> ". $row["namaSendiri"]. " </td>
<td>" . $row["namaBapa"] . "</td>
</tr>";
}
} else {
echo "0 results";
}
$conn->close();
if(empty(trim(isset($_POST["padamData"])))){
echo "<br><br><br> Masukkan ID Data yang Hendak Di Padam";
} else
{
$padamData = trim($_POST['padamData']);
//SQL, change into your table name and columnid
$sql2 = "DELETE FROM pelanggan WHERE idPelanggan=$padamData ";
if ($conn2->query($sql2) === TRUE) {
echo "<br><br>Rekod telah berjaya dipadam";
} else {
echo "Error: " . $sql2 . "<br>" . $conn2->error;
}
$conn2->close();
}
?>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<table>
<br>
<tr>
<td>No ID Data Yang Hendak Di Padam</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>
<label for="padamData">No ID:</label>
<input type="text" name="padamData" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit">
<input type="reset" value="Semula">
</td>
</tr>
</table>
</form>
<?php
include 'footer.php';
?>
</body>
</html>