-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (78 loc) · 3.69 KB
/
index.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
<?php
// include function file
require_once 'function.php';
// Deletion
if (isset($_GET['del'])) {
// Getting deletion row id
$rid = $_GET['del'];
$deletedata = new DB_con();
$sql = $deletedata->delete($rid);
if ($sql) {
// Message for successful deletion
echo "<script>alert('Record deleted successfully');</script>";
echo "<script>window.location.href='index.php'</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PHP CRUD OOPs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h3>PHP CRUD Operations using PHP OOP</h3>
<hr />
<div style="padding-left: 1000px; padding-bottom:10px">
<a href="insert.php"><button class="btn btn-primary">Insert Record</button></a>
</div>
<div class="table-responsive">
<table id="mytable" class="table table-bordered table-striped">
<thead>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Contact Number</th>
<th>Address</th>
<th>Posting Date</th>
<th>Edit</th>
<th>Delete</th>
</thead>
<tbody>
<?php
$fetchdata = new DB_con();
$sql = $fetchdata->fetchdata();
$cnt = 1;
while ($row = mysqli_fetch_array($sql)) {
?>
<tr>
<td><?php echo htmlentities($cnt); ?></td>
<td><?php echo htmlentities($row['FirstName']); ?></td>
<td><?php echo htmlentities($row['LastName']); ?></td>
<td><?php echo htmlentities($row['EmailId']); ?></td>
<td><?php echo htmlentities($row['ContactNumber']); ?></td>
<td><?php echo htmlentities($row['Address']); ?></td>
<td><?php echo htmlentities($row['PostingDate']); ?></td>
<td><a href="update.php?id=<?php echo htmlentities($row['id']); ?>"><button class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-pencil"></span> Edit</button></a></td>
<td><a href="index.php?del=<?php echo htmlentities($row['id']); ?>"><button class="btn btn-danger btn-xs" onClick="return confirm('Do you really want to delete?')"><span class="glyphicon glyphicon-trash"></span> Delete</button></a></td>
</tr>
<?php
// for serial number increment
$cnt++;
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</body>
</html>