-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex_2.php
102 lines (80 loc) · 2.47 KB
/
index_2.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
<!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
$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>