SHARE
TWEET

Untitled

a guest Dec 9th, 2019 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. ini_set('display_errors', 1);
  3. //var_dump($_GET['input']);
  4. $Fields = array();
  5. $conn =  new mysqli("jestrab.kolej.mff.cuni.cz", "martin", "Kos", "martin_skola");
  6. $select = "select * from Report join Senzor on Senzor.id=Report.Senzor_id;";
  7. $selectResoult = mysqli_query($conn, $select);
  8. $get_info = mysqli_fetch_assoc($selectResoult);
  9.  
  10. //var_dump($selectResoult);
  11. foreach (array_keys($get_info) as $columnName) {
  12.   array_push($Fields, $columnName);
  13. }
  14. $FilterSetted=true;
  15. $selectResoult = mysqli_query($conn, $select);
  16. if(isset($_GET['input'])&&is_array($_GET['input'])){
  17.   $FilterFields=$_GET['input'];
  18. }else{
  19.   $FilterFields=array();
  20.   $FilterSetted=false;
  21. }
  22. if (isset($_GET['onlyData']) && $_GET['onlyData'] == "true") {
  23.   echo '<div class="datagrid" id="datagrid">
  24.    <table>
  25.        <tr>';
  26.   if (!$FilterSetted) {
  27.     foreach ($Fields as $field) {
  28.       printf("<th>%s</th>", $field);
  29.     }
  30.     echo '</tr>';
  31.     while ($row = mysqli_fetch_array($selectResoult)) {
  32.       echo '<tr>';
  33.       foreach ($Fields as $collom) {
  34.         printf("<th>%s</th>", $row[$collom]);
  35.       }
  36.       echo '</tr>';
  37.     }
  38.     echo '</table></div>';
  39.   } else {
  40.     for ($i = 0; $i < count($FilterFields); $i++) {
  41.       printf("<th>%s</th>", $FilterFields[$i]);
  42.     }
  43.     echo '</tr>';
  44.     while ($row = mysqli_fetch_array($selectResoult)) {
  45.       echo '<tr>';
  46.       for ($i = 0; $i < count($FilterFields); $i++) {
  47.         printf("<th>%s</th>", $row[$FilterFields[$i]]);
  48.       }
  49.       echo '</tr>';
  50.     }
  51.     echo '</table></div>';
  52.   }
  53.   exit();
  54. }
  55. ?>
  56. <html>
  57.  
  58. <head>
  59.   <title>Data log</title>
  60.   <link rel="stylesheet" type="text/css" href="style.css">
  61.   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  62.   <script src="./p5.min.js"></script>
  63.   <script src="script.js" charset="utf-8"></script>
  64. </head>
  65.  
  66. <body>
  67.   <?php
  68.   echo '<div class="dropdown">
  69.  <button onclick="toggleDropDown()" class="dropbtn">Filter</button>
  70.  <div id="myDropdown" class="dropdown-content">
  71.    <form action="index.php">';
  72.     foreach ($Fields as $fieldName) {
  73.       if (in_array($fieldName, $FilterFields)) {
  74.         printf('<label class="myInput"><input type="checkbox" name="input[]" value="%s" checked/>%s</label><br/>', $fieldName, $fieldName);
  75.       } else {
  76.         printf('<label class="myInput"><input type="checkbox" name="input[]" value="%s" />%s</label><br/>', $fieldName, $fieldName);
  77.       }
  78.     }
  79.   echo ' <input type="submit" value="Submit" class="submit"/>
  80. </form>
  81. <button onclick="resetInputs()" class="submit">Reset Input</button>
  82. </div>
  83. </div>
  84. <div class="datagrid" id="datagrid">
  85.  <table>
  86.      <tr>';
  87.   if (count($FilterFields) == 0) {
  88.     foreach ($Fields as $field) {
  89.       printf("<th>%s</th>", $field);
  90.     }
  91.     echo '</tr>';
  92.     while ($row = mysqli_fetch_array($selectResoult)) {
  93.       echo '<tr>';
  94.       foreach ($Fields as $collom) {
  95.         printf("<th>%s</th>", $row[$collom]);
  96.       }
  97.       echo '</tr>';
  98.     }
  99.     echo '</table></div>';
  100.   } else {
  101.     for ($i = 0; $i < count($FilterFields); $i++) {
  102.       printf("<th>%s</th>", $FilterFields[$i]);
  103.     }
  104.     echo '</tr>';
  105.     while ($row = mysqli_fetch_array($selectResoult)) {
  106.       echo '<tr>';
  107.       for ($i = 0; $i < count($FilterFields); $i++) {
  108.         printf("<th>%s</th>", $row[$FilterFields[$i]]);
  109.       }
  110.       echo '</tr>';
  111.     }
  112.     echo '</table></div>';
  113.   }
  114.   echo '<button onclick="togleGraphView()" class="dropbtn">Togle Graph</button>';
  115.   echo '<button onclick="togleRefrash()" class="dropbtn red">Auto refrash</button>';
  116.   ?>
  117. </body>
  118.  
  119. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top