Browse Source

adding sql back indo website config

koellenberger 2 năm trước cách đây
mục cha
commit
8eb782169d
1 tập tin đã thay đổi với 71 bổ sung0 xóa
  1. 71 0
      public/index.php

+ 71 - 0
public/index.php

@@ -66,6 +66,77 @@
           table th#green {font-weight:normal; background-color:#bdffce;}
         </style>
 
+        <?php
+          $file = "recentSQLName.txt";
+          $f = fopen($file, 'r');
+          $tableName = fgets($f);
+          fclose($f);
+          echo "<h1>Checklist history - $tableName</h1>";
+
+          $db= new SQLite3("data/mydb.sqlite");
+          $db->exec("CREATE TABLE IF NOT EXISTS $tableName(id INTEGER PRIMARY KEY NOT NULL, Run_Range Text, Mode Text, Submitted Text, Author Text, HV_K65 Text, HV_TankPotential Text, BIXS Text, LARA Text, LARA_crosscheck Text, FBM Text, RW Text, Run_Length Text, Data_Size Text, FPD_Energy Text, Grid_sync Text, Rate_300 Text, Rate_90 Text, Tritium_Purity Text, Summary Text )");
+          $sql_select="SELECT * FROM $tableName ORDER BY ID DESC";
+          $result=$db->query($sql_select);
+          echo "<table width='100%'>";
+          echo "<tr>";
+          $numColumns=$result->numColumns();
+          for ($i = 1; $i < $numColumns; $i++)
+          {
+              $colname=$result->columnName($i);
+              $colname = str_replace('_', ' ', $colname);
+              if ($i < 5){
+                echo "<th>$colname</th>";
+              }
+              else {
+                echo "<th class='vertical'><div class='vertical'>$colname</div></th>";
+              }
+
+          }
+          echo "</tr>";
+          $rowCount = 0;
+          $lastChecked = '';
+
+          while($row = $result->fetchArray(SQLITE3_NUM))
+          {
+              echo "<tr>";
+              for ($i = 1; $i < $numColumns-1; $i++)
+              {
+                  $value=$row[$i];
+                  if ($rowCount == 0 && $i == 1){
+                    $lastChecked = "runs ($value); at";
+                  }
+                  if($rowCount == 0 && $i == 3){
+                    $lastChecked = "$lastChecked $value (UTC)";
+                    echo "<script>localStorage.setItem('lastChecked', '$lastChecked')</script>";
+                  }
+
+                  if ($value == "good"){
+                    echo "<th id='green'>$value</th>";
+                  }
+                  elseif ($value == "bad") {
+                    echo "<th id='red'>$value</th>";
+                  }
+                  else {
+                    echo "<th id='normal'>$value</th>";
+                  }
+              }
+              $value=$row[$numColumns-1];
+              echo "<th><button type='submit' onclick='detailedInfo(\"$value\")' id='details'>details</button><th>";
+              #echo "<th id='normal'>$value</th>";
+              echo "</tr>";
+              $rowCount += 1;
+          }
+          echo "</table>";
+        ?>
+
+        <script type="text/javascript">
+            function detailedInfo(message) {
+                var str = message;
+                var alert_string = str.replace(/<br?>/gi, "\n").replace(/<pre?>/gi, "").replace(/<\/pre?>/gi, "");
+                alert(alert_string)
+            }
+        </script>
+
     </center>
   </body>
 </html>