-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
138 lines (138 loc) · 5.59 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
include"inc/db.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Saifur's - Student Vocabulary</title>
<!-- General CSS Files -->
<link rel="stylesheet" href="admin/assets/css/app.min.css">
<link rel="stylesheet" href="admin/assets/bundles/bootstrap-social/bootstrap-social.css">
<!-- Template CSS -->
<link rel="stylesheet" href="admin/assets/css/style.css">
<link rel="stylesheet" href="admin/assets/css/components.css">
<!-- Custom style CSS -->
<link rel="stylesheet" href="admin/assets/css/custom.css">
<link rel='shortcut icon' type='image/x-icon' href='admin/assets/img/logo.png' />
</head>
<body>
<div id="app">
<section class="section">
<div class="container mt-5">
<div class="row">
<div class="col-lg-12 col-md-12">
<div class="logoWrapper">
<h1 style="font-size:25px;color: #6777ef;text-align: center;margin-bottom: 15px;">Saifurs - Student Vocabulary</h1>
</div>
</div>
<div class="col-lg-12 col-md-12">
<div class="card">
<div class="card-header" style="display: flex;">
<h4>All Vocabularies</h4>
<div class="card-header-form">
<form action="search.php" method="GET">
<div class="input-group">
<input type="text" class="form-control" name="search" placeholder="Search">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="fas fa-search"></i></button>
</div>
</div>
</form>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-md">
<tbody>
<tr>
<th style="width: 5%">ID</th>
<th style="width: 20%">Main Word</th>
<th style="width: 20%">Meaning</th>
<th style="width: 30%">Synonyms</th>
<th style="width: 25%">Antonyms</th>
</tr>
<?php
$limit = 6;
if (isset($_GET['page'])) {
$page = $_GET['page'];
}else{
$page = 1;
}
$offset = ($page-1)*$limit;
$readWord = "SELECT * FROM words ORDER BY wId ASC LIMIT {$offset},{$limit}";
$readWordResult = mysqli_query($conn,$readWord) or die("Read words for home page query failed - Check index.php");
if (mysqli_num_rows($readWordResult)>0) {
$serial = $offset+1;
while ($word = mysqli_fetch_assoc($readWordResult)) {?>
<tr>
<td><?php echo $serial; ?></td>
<td><?php echo $word['word']; ?></td>
<td><?php echo $word['meaning']; ?></td>
<td><?php echo $word['synonym']; ?></td>
<td><?php echo $word['antonym']; ?></td>
</tr>
<?php
$serial++;
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="card-footer text-right">
<nav class="d-inline-block">
<?php
$paginationQuery = "SELECT * FROM words";
$paginationQResult = mysqli_query($conn,$paginationQuery);
if (mysqli_num_rows($paginationQResult)>6) {
$totalRecords = mysqli_num_rows($paginationQResult);
$totalPage = ceil($totalRecords/$limit);
echo '<ul class="pagination mb-0">';
if ($page>1) {?>
<li class="page-item">
<a class="page-link" href="index.php?page=<?php echo $page-1; ?>">
<i class="fas fa-chevron-left"></i>
</a>
</li>
<?php }
for ($i=1; $i <= $totalPage ; $i++) {
if ($i==$page) {?>
<li class="page-item active">
<a class="page-link" href="index.php?page=<?php echo $i; ?>"><?php echo $i; ?></a>
</li>
<?php }else{?>
<li class="page-item">
<a class="page-link" href="index.php?page=<?php echo $i; ?>"><?php echo $i; ?></a>
</li>
<?php }
}
if ($totalPage > $page) {?>
<li class="page-item">
<a class="page-link" href="index.php?page=<?php echo $page+1; ?>">
<i class="fas fa-chevron-right"></i>
</a>
</li>
<?php }
echo '</ul>';
}
?>
</nav>
</div>
</div>
<div class="mt-5 text-muted text-center">
Want to add word? <a href="login.php">Add</a>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- General JS Scripts -->
<script src="admin/assets/js/app.min.js"></script>
<script src="admin/assets/js/scripts.js"></script>
<script src="admin/assets/js/custom.js"></script>
</body>
</html>