Genesetdb

From Pathology Education Instructional Resource
Jump to: navigation, search
<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>