-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch-go-result.php
125 lines (115 loc) · 3.47 KB
/
search-go-result.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
<?php
session_start();
require("connect.inc.php");
if(isset($_POST["pageid"])&&!empty($_POST["pageid"]))
@$pageid=$_POST["pageid"];
else $pageid=1;
$sql=$_SESSION["query"];
$countquery=$_SESSION["countquery"];
$sql=$sql." LIMIT ".(($pageid-1)*25).",25";//add limit for paging
//colnames to fetch
$colNames=array("seqid","seqdesc","go","enzymecodes");
//colnames to displays
$displayColNames=array("UnigeneID","Sequence Description","Gene Ontology", "Enzyme Code");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Search result</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="http://getbootstrap.com.vn/examples/equal-height-columns/equal-height-columns.css" />
<link rel="stylesheet" type="text/css" href="resources/css/custom-home.css">
<link rel="stylesheet" type="text/css" href="">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
.pagination-container{
margin-left: 40%;
margin-bottom: 20px;
}
.pagination-form{
}
.submit-pagination-button{
float: left;
border:1px solid rgba(255, 0, 0, 0.3);
background-color: rgba(119, 119, 119, 0.12);
margin: 3px;
padding:10px;
border-radius: 5px;
}
</style>
</head>
<body>
<?php include("navbar.inc.php") ?>
<?php
$retval = mysql_query( $countquery);
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($retval, MYSQL_NUM );
$rec_count = $row[0];
//echo $rec_count;
?>
<!-- page body container-->
<div class="container-fluid">
<?php if($pageid == floor($rec_count/25+1)){ ?>
<p class="result"> <?="(".((($pageid-1)*25)+1)."-".((($pageid-1)*25)+($rec_count%25)).") of ".$rec_count." results"?></p>
<?php }
else{
?>
<p class="result"><?="(".((($pageid-1)*25)+1)."-".((($pageid-1)*25)+25).") of ".$rec_count." results"?></p>
<?php } ?>
<table class="table table-hover table-responsive">
<thead>
<tr>
<?php
foreach ($displayColNames as $key) {
echo "<th>".$key."</th>";
}
?>
</tr>
</thead>
<tbody>
<?php
//fetching required data
if ( $query_run = mysql_query( $sql) ) {
while ( $query_row=mysql_fetch_assoc ( $query_run ) ) {
for($i=0;$i<sizeof($colNames);$i++){
$data[$i] = $query_row[$colNames[$i]]; //fetch data of each row in an array data
}
echo "<tr>";
foreach ($data as $key)
echo "<td>".$key."</td>";
echo "</tr>";
}
}
else {
echo mysql_error();
}
?>
</tbody>
</table>
</div>
<!-- end container -->
<hr>
<div class="container-fluid pagination-container">
<?php
function pageidform($page,$disp){
echo "<div class='pagination-form'><form action='search-go-result.php' method='post'>";
echo "<input type='hidden' name='pageid' value=".$page.">";
echo "<input class='submit-pagination-button' type='submit' value='".$disp."'>";
echo "</form>";
}
pageidform(1,"First");
if($pageid!=1)
pageidform($pageid-1,"Prev");
if($pageid!=floor($rec_count/25+1))
pageidform($pageid+1,"Next");
pageidform(floor($rec_count/25+1),"Last");
//echo $rec_count." page id=".$pageid;
?>
</div>
</body>
</html>