-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_3.php
139 lines (110 loc) · 3.32 KB
/
index_3.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
<!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
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'>
</td>
<td>
<select name = 'biotype_selected'>
</select>
</td>
<td>
<select name = 'chromosome_selected'>
</select>
</td>
<td>
<input type = 'text' name = 'description_selected'>
</td>
</tr>
</table>
<input type='submit' value='Search' class = 'submit' />
</form> <br />
";
$query = "select * from gene_data where biotype = 'snoRNA'";
$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</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></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>