-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_example.php
210 lines (172 loc) · 5.33 KB
/
index_example.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "genes";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<ul id="menu">
<li><a href="#">Home</a></li>
<li><a href="index.php">Search</a></li>
<li><a href="add.php">Upload</a></li>
<li><a href="#">Download</a></li>
<li><a href="#">Contact</a></li>
</ul>
<?php
$biotypes = mysqli_query($conn, "SELECT distinct biotype from gene_data order by biotype");
$chromosomes = mysqli_query($conn, "SELECT distinct chr from gene_data order by chr");
if(isset($_POST['gene_name_selected']))
{
$gene_name_selected = $_POST['gene_name_selected'];
}
else
{
$gene_name_selected = '';
}
if(isset($_POST['chromosome_selected']))
{
$chromosome_selected = $_POST['chromosome_selected'];
}
else
{
$chromosome_selected = '1';
}
if(isset($_POST['biotype_selected']))
{
$biotype_selected = $_POST['biotype_selected'];
}
else
{
$biotype_selected = 'antisense';
}
if(isset($_POST['description_selected']))
{
$description_selected = $_POST['description_selected'];
}
else
{
$description_selected = '';
}
print "
<br /><br />
<form action = 'index.php' method = 'POST' >
<table class = 'search'>
<tr>
<td>Gene name</td>
<td>Biotype</td>
<td>Chromosome</td>
<td>Description</td>
</tr>
<tr>
<td>
<input type = 'text' name = 'gene_name_selected' value = '$gene_name_selected'>
</td>
<td>
<select name = 'biotype_selected'>";
while($row = mysqli_fetch_assoc($biotypes))
{
$biot = $row["biotype"];
print "<OPTION>" . $biot;
}
print "
</select>
</td>
<td>
<select name = 'chromosome_selected'>";
while($row = mysqli_fetch_assoc($chromosomes))
{
$chr = $row["chr"];
print "<OPTION>" . $chr;
}
print "
</select>
</td>
<td>
<input type = 'text' name = 'description_selected' value = '$description_selected'>
</td>
</tr>
</table>
<input type='submit' value='Search' class = 'submit' />
</form> <br />
";
if($gene_name_selected)
{
print "<b>Gene name</b>: $gene_name_selected<br />";
}
if($biotype_selected)
{
print "<b>Biotype</b>: $biotype_selected<br />";
}
if($chromosome_selected)
{
print "<b>Chromosome</b>: $chromosome_selected<br />";
}
if($description_selected)
{
print "<b>Description</b>: $description_selected<br />";
}
$query = "select * from gene_data where gene_name like '%$gene_name_selected%' and biotype = '$biotype_selected' and chr = '$chromosome_selected' and description like '%$description_selected%'";
$result = mysqli_query($conn, $query);
$number = mysqli_num_rows($result);
print "<br /><b>Number of records</b>: $number<br /><br />";
if (mysqli_num_rows($result) > 0)
{
print "
<table class = 'data'>
<tr class = 'header'>
<td>ID</td>
<td>Gene</td>
<td>Transcript</td>
<td>Protein</td>
<td>Chromosome: Start-End, Strand</td>
<td>Gene name</td>
<td>Biotype</td>
<td>Description</td>
";
// output data of each row
while($row = mysqli_fetch_assoc($result))
{
$id = $row["id"];
$gene_id = $row["gene_id"];
$transcript_id = $row["transcript_id"];
$protein_id = $row["protein_id"];
$description = $row["description"];
$chr = $row["chr"];
$start = $row["start"];
$end = $row["end"];
$strand = $row["strand"];
$gene_name = $row["gene_name"];
$biotype = $row["biotype"];
print "
<tr class = 'records'>
<td class = 'records'>$id <a href = edit.php?id=$id>Edit</a> <a href = remove.php?id=$id>Remove</a></td>
<td class = 'records'><a href = http://www.ensembl.org/Homo_sapiens/Gene/Summary?g=$gene_id>$gene_id</a></td>
<td class = 'records'><a href = 'http://www.ensembl.org/Homo_sapiens/Transcript/Summary?t=$transcript_id'>$transcript_id</a> <a href = transcripts.php?transcript_id=$transcript_id>SEQ</a></td>
<td class = 'records'><a href = http://www.ensembl.org/Homo_sapiens/Transcript/ProteinSummary?db=core;t=$transcript_id>$protein_id</a></td>
<td class = 'records'>$chr: $start-$end, $strand</td>
<td class = 'records'>$gene_name</td>
<td class = 'records'>$biotype</td>
<td class = 'records'>$description</td>
</tr>
";
}
print "</table>";
}
else
{
echo "0 results";
}
?>
</body>
</html>