-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-database-table.php
72 lines (65 loc) · 2.77 KB
/
show-database-table.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
<?php
include("css/css/css.php");
include("include/db.php");
include("include/session.php");
include("include/sidebar.php");
$selectedDatabase = $dbname; // Replace with the actual selected database name
$tables = $connect->query("SHOW TABLES")->fetchAll(PDO::FETCH_COLUMN);
?>
<div class="container-fluid">
<div class="row">
<div class="col-sm-10 title">
<h1><i class="fa fa-bars"></i> DASHBOARD</h1>
</div>
<div class="col-sm-12">
<?php
echo failed_alert();
echo success_alert();
?>
<div class="content">
<!-- ... rest of your HTML code ... -->
<table class="table">
<a class="label label-primary" href="creat-table.php">Creat New Table</a>
<thead>
<tr>
<th scope="col">SrNo</th>
<th scope="col">Table Name</th>
<th scope="col">Status</th>
<th scope="col">Date Of Creation</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($tables as $table) {
// Retrieve table creation time from INFORMATION_SCHEMA
$query = "SELECT CREATE_TIME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?";
$stmt = $connect->prepare($query);
$stmt->execute([$selectedDatabase, $table]);
$creationTime = $stmt->fetchColumn();
$rowCount = $connect->query("SELECT COUNT(*) FROM $table")->fetchColumn();
if ($rowCount === '0') {
$status = " (Table is empty)";
} else {
$status = " (Not Empty) ";
}
$i++;
?>
<tr>
<th scope="row"><?php echo $i ?></th>
<td><?php echo $table ?></td>
<td><?php echo $status ?></td>
<td><?php echo $creationTime ?></td>
<td><a class="btn btn-danger" href="table-drop.php?table-name=<?php echo $table ?>">Drop</a> | <a class="btn btn-info" href="table-structer.php?table-name=<?php echo $table ?>">Structure</a></td>
<td></td>
</tr>
<tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include("include/footer.php"); ?>