Difference between revisions of "Genesetdb"
Seung Park (talk | contribs) |
Seung Park (talk | contribs) |
||
Line 1: | Line 1: | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<html> | <html> | ||
<head> | <head> | ||
− | <title>genetable</title> | + | <title>genetable for the ooga</title> |
</head> | </head> | ||
<body> | <body> | ||
Line 18: | Line 11: | ||
<th>Gene ID</th> | <th>Gene ID</th> | ||
</tr> | </tr> | ||
− | + | <?php | |
− | $ | + | $con= mysqli_connect("localhost", "ooga", "booga","genesetdb"); |
− | + | if(mysqli_connect_errno()) | |
− | |||
− | |||
− | |||
{ | { | ||
− | + | die( "could not connect: " . mysqli_connect_error()); | |
− | + | } | |
− | + | // Get absolute count of rows in table "genesets"; export | |
− | + | // that count into a variable called $pidcount | |
+ | $sql = "SELECT COUNT(*) AS cnt FROM `genesets`;"; | ||
+ | $result = mysqli_query($con, $sql); | ||
+ | $row = mysqli_fetch_array($result); | ||
+ | $pidcount = $row['cnt']; | ||
+ | /* | ||
+ | Now get the entirety of genesets and CHOWN THE HELL OUT OF IT! | ||
+ | Where "CHOWNing" in this case means the generation of a table | ||
+ | that looks roughly like: | ||
+ | pid geneid | ||
+ | --- ------ | ||
+ | 1 $row[3] | ||
+ | 1 $row[4] | ||
+ | 1 $row[5] | ||
+ | ... | ||
+ | 1 $row[203] | ||
+ | 2 $row[3] | ||
+ | ... | ||
+ | */ | ||
+ | $sql = "SELECT * FROM `genesets`;"; | ||
+ | $result = mysqli_query($con, $sql); | ||
+ | while($row = mysqli_fetch_array($result)) | ||
+ | { | ||
+ | for($i = 3; $i<204; $i++) | ||
+ | { | ||
+ | $booga = "INSERT INTO finalgeneset(exp,geneid) VALUES(" . $row[0] . "," . $row[$i] . ");"; | ||
+ | $ooga = mysqli_query($con, $booga); | ||
+ | echo ' | ||
<tr> | <tr> | ||
− | <td>' . $ | + | <td>' . $row[0] . '</td> |
− | <td>' . $row[$ | + | <td>' . $row[$i] . '</td> |
</tr> | </tr> | ||
− | + | '; | |
− | + | } | |
− | |||
− | |||
− | |||
} | } | ||
− | + | ?> | |
</table> | </table> | ||
</body> | </body> | ||
</html> | </html> | ||
− | + | </syntaxhighlight> | |
− | |||
− | </ |
Revision as of 03:30, 26 October 2013
<html>
<head>
<title>genetable for the ooga</title>
</head>
<body>
<h1> Genetable</h1>
<table border="1">
<tr>
<th>Experiment Number</th>
<th>Gene ID</th>
</tr>
<?php
$con= mysqli_connect("localhost", "ooga", "booga","genesetdb");
if(mysqli_connect_errno())
{
die( "could not connect: " . mysqli_connect_error());
}
// Get absolute count of rows in table "genesets"; export
// that count into a variable called $pidcount
$sql = "SELECT COUNT(*) AS cnt FROM `genesets`;";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$pidcount = $row['cnt'];
/*
Now get the entirety of genesets and CHOWN THE HELL OUT OF IT!
Where "CHOWNing" in this case means the generation of a table
that looks roughly like:
pid geneid
--- ------
1 $row[3]
1 $row[4]
1 $row[5]
...
1 $row[203]
2 $row[3]
...
*/
$sql = "SELECT * FROM `genesets`;";
$result = mysqli_query($con, $sql);
while($row = mysqli_fetch_array($result))
{
for($i = 3; $i<204; $i++)
{
$booga = "INSERT INTO finalgeneset(exp,geneid) VALUES(" . $row[0] . "," . $row[$i] . ");";
$ooga = mysqli_query($con, $booga);
echo '
<tr>
<td>' . $row[0] . '</td>
<td>' . $row[$i] . '</td>
</tr>
';
}
}
?>
</table>
</body>
</html>