-
Notifications
You must be signed in to change notification settings - Fork 0
/
genes.php
95 lines (82 loc) · 2.87 KB
/
genes.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
<?php
require('./nav.inc.php');
$limit = 17;
if(isset($_GET['page'])) {
$page = $_GET['page'];
}
else {
$page = 1;
}
$offset = ($page - 1) * $limit;
$sql = "SELECT * FROM genes LIMIT {$offset}, {$limit}";
$result = mysqli_query($con, $sql);
?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<div class="landing-gene" data-aos="fade-left" data-aos-duration="1000">
<div class="container">
<h1 class="mb-2">Genes</h1>
<table class="table text-center table-striped table-bordered table-sm" >
<thead class="thead-dark">
<tr>
<th class="p-2">Gene Id</th>
<th class="p-2">Symbol</th>
<th class="p-2">Map Location</th>
<th class="p-2">Chromosome</th>
<th class="p-2">Actions</th>
</tr>
</thead>
<tbody>
<?php
if(!$result) {
echo "ERROR";
}
while($data = mysqli_fetch_assoc($result)) {
$geneId = $data['gene_id'];
$symbol = $data['symbol'];
$mapLocation = $data['map_location'];
$chromosome = $data['chromosome'];
echo '
<tr>
<td class="p-2">'.$geneId.'</td>
<td class="p-2">'.$symbol.'</td>
<td class="p-2">'.$mapLocation.'</td>
<td class="p-2">'.$chromosome.'</td>
<td class="p-2"><a class="btn btn-secondary text-light" href="gene.php?id='.$geneId.'">Read more</td>
</tr>
';
}
?>
</tbody>
</table>
<?php
$paginationSql = "SELECT * FROM genes";
$paginationResult = mysqli_query($con, $paginationSql);
if(mysqli_num_rows($paginationResult) > 0) {
$total_records = mysqli_num_rows($paginationResult);
$total_page = ceil($total_records / $limit);
}
?>
<nav>
<ul class="pagination justify-content-center">
<?php
if($page > 1) {
echo '<li class="page-item"><a class="page-link text-secondary" href="./genes.php?page='.($page - 1).'">Previous</a></li>';
}
for($i = 1; $i <= $total_page; $i++) {
$active = "";
if($page == $i) {
$active = " active";
}
echo '<li class="page-item '.$active.'"><a class="page-link text-secondary" href="./genes.php?page='.$i.'">'.$i.'</a></li>';
}
if($page < $total_page) {
echo '<li class="page-item"><a class="page-link text-secondary" href="./genes.php?page='.($page + 1).'">Next </a></li>';
}
?>
</ul>
</nav>
</div>
</div>
<?php
require('./footer.inc.php');
?>