-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelete.php
85 lines (70 loc) · 3.05 KB
/
Delete.php
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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Journey Details</title>
</head>
<body>
<div class="container-fluid">
<h1 class="display-4">Trip Details : </h1>
<?php
$conn = mysqli_connect("localhost","root","","dbArman");
if($conn){
echo "<br>";
echo '
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Connection Established !</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
';
// $sql2 = "delete from `trip` Where `dest`='Rayagada'";
// $res2 = mysqli_query($conn,$sql2);
$sql2 = "delete from `trip` where `dest`='Rayagada' limit 2"; // limits to delete only 2 records
$res2 = mysqli_query($conn,$sql2);
if($res2){
echo "Records deleted :".mysqli_affected_rows($conn);
}else{
echo "Failed to delete".mysqli_error($conn);
}
$sql = "select * from `trip`";
$res = mysqli_query($conn,$sql);
$num = mysqli_num_rows($res);
// echo $num;
echo "<h4>$num records found in database ..</h4>";
echo '
<table class="table table-dark table-striped">
<thead>
<tr>
<th scope="col">S.no</th>
<th scope="col">Name</th>
<th scope="col">Destination</th>
</tr>
</thead>
<tbody>';
if($num>0){
while($row = mysqli_fetch_assoc($res)){
echo '
<tr>
<th scope="row">'.$row['S.no'].'</th>
<td>'.$row['Name'].'</td>
<td>'.$row['dest'].'</td>
</tr>
';
}
}
echo '
</tbody>
</table>';
}else{
die("Sorry failed to connect due to ".mysqli_connect_error());
}
?>
</div>
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>