commit 931940406bebfc624b1089b5cbf82a77b66c3524
parent 54058904ff5d1a199cffd3e18cd87e46a998ae4a
Author: LennartSchroot <[email protected]>
Date: Tue, 6 Jun 2023 14:49:19 +0200
query shit
Diffstat:
5 files changed, 117 insertions(+), 10 deletions(-)
diff --git a/.idea/.gitignore b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/php.xml b/.idea/php.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="MessDetectorOptionsConfiguration">
+ <option name="transferred" value="true" />
+ </component>
+ <component name="PHPCSFixerOptionsConfiguration">
+ <option name="transferred" value="true" />
+ </component>
+ <component name="PHPCodeSnifferOptionsConfiguration">
+ <option name="highlightLevel" value="WARNING" />
+ <option name="transferred" value="true" />
+ </component>
+ <component name="PhpProjectSharedConfiguration" php_language_level="8.0">
+ <option name="suggestChangeDefaultLanguageLevel" value="false" />
+ </component>
+ <component name="PhpStanOptionsConfiguration">
+ <option name="transferred" value="true" />
+ </component>
+ <component name="PsalmOptionsConfiguration">
+ <option name="transferred" value="true" />
+ </component>
+</project>
+\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
+</project>
+\ No newline at end of file
diff --git a/Model/Key.php b/Model/Key.php
@@ -1,12 +1,81 @@
<?php
Class Key{
- function myfunction($key):string{
+ function myfunction($key){
+ $db = new mysqli("86.92.67.21", "friedel", "hailiwa", "wap2");
$t = new Lollipop\Template();
- //do sql query met $key
- //return data als array
- //geef array mee aan template
- $table = "<table";
- $data = ["tabel" => $table];
- return $t->template("views/panda.html", $data);
+ $array = [];
+ $query = "SELECT *
+ FROM weather_data wd
+ JOIN station s ON wd.station_name = s.name
+ JOIN contract_station cs ON cs.station_name = s.name
+ JOIN contract c ON cs.contract_id = c.contract_id
+ WHERE c.token = '3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk'
+ LIMIT 5";
+ $stmt = mysqli_prepare($db, $query);
+ $stmt->execute();
+ $data = $stmt->get_result();
+// $table = "<table";
+// $data = ["tabel" => $table];
+ while ($row = $data->fetch_assoc()) {
+ $array[] = $row;
+ };
+ if ($array != null) {?>
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th> Station name </th>
+ <th> Date & Time </th>
+ <th> Validated </th>
+ <th> Temperature </th>
+ <th> Dewpoint </th>
+ <th> Sea pressure </th>
+ <th> Station pressure </th>
+ <th> Visibility </th>
+ <th> Wind speed </th>
+ <th> Precipitation </th>
+ <th> Snow depth </th>
+ <th> Events </th>
+ <th> Cloud count </th>
+ <th> Wind direction </th>
+ </tr>
+ </thead>
+ <tbody>
+
+ </tbody>
+ <?php
+ foreach($weather_data as $data) {
+ $link = "/search_data?station=" . $data->station_name;
+ echo "<tr>";
+ echo "<td><a href='" . $link . "'>" . $data->station_name . "</a></td>";
+ echo "<td>" . $data->date_time . "</td>";
+ echo "<td>" . $data->validated . "</td>";
+ echo "<td>" . $data->temperature . "</td>";
+ echo "<td>" . $data->dew_point . "</td>";
+ echo "<td>" . $data->pressure_sea . "</td>";
+ echo "<td>" . $data->pressure_station . "</td>";
+ echo "<td>" . $data->visibility . "</td>";
+ echo "<td>" . $data->wind_speed . "</td>";
+ echo "<td>" . $data->precipitation . "</td>";
+ echo "<td>" . $data->snow_depth . "</td>";
+ echo "<td>" . $data->events . "</td>";
+ echo "<td>" . $data->cloud_count . "</td>";
+ echo "<td>" . $data->wind_direction . "</td>";
+ echo "</tr>";
+ }
+ ?>
+ </tbody>
+ </table>
+ return $array;
}
-}
-\ No newline at end of file
+}
+
+
+
+
+
+//SELECT *
+//FROM weather_data wd
+//JOIN station s ON wd.station_name = s.name
+//JOIN contract_station cs ON cs.station_name = s.name
+//JOIN contract c ON cs.contract_id = c.contract_id
+//WHERE c.token = "3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk"
+\ No newline at end of file
diff --git a/index.php b/index.php
@@ -17,7 +17,7 @@ $router->addRoute(["POST"], "/", function($vars){
$router->addRoute(["GET"], "/dashboard", "views/dashboard.php");
$router->addRoute(["GET"], "/api/:data", function($vars) {
$key = new Key;
- echo $key->myfunction($vars);
+ var_dump($key->myfunction($vars));
});
$router->route();
\ No newline at end of file