diff --git a/uebung10/Database.php b/uebung10/Database.php new file mode 100644 index 0000000..873949e --- /dev/null +++ b/uebung10/Database.php @@ -0,0 +1,74 @@ +connection = new mysqli($host, $user, $password, $database); + } + + /** + * Schließt die Verbindung zru Datenbank + */ + public function __destruct() + { + $this->connection->close(); + } + + public function getQuestions($n = 0) + { + if ($n == 0) { + $sql = "SELECT * FROM questions"; + } else { + //n ist gesetzt + $sql = "SELECT * FROM questions LIMIT $n"; + } + + $result = $this->connection->query($sql); + $resultArray = []; + + while ($line = $result->fetch_assoc()) { + array_push($resultArray, $line); + } + + $result->free(); + + return $resultArray; + } + + public function getQuestion($id) + { + $result = $this->connection->query("SELECT * FROM questions WHERE id = $id LIMIT 1"); + + $resultArray = []; + + while ($line = $result->fetch_assoc()) { + array_push($resultArray, $line); + } + + $result->free(); + + return $resultArray[0]; + } + + +} diff --git a/uebung10/notes.js b/uebung10/notes.js new file mode 100644 index 0000000..a093658 --- /dev/null +++ b/uebung10/notes.js @@ -0,0 +1,142 @@ + +//button +// +// + + +//CSS screens per default nicht anzeigen +// + + + +//HTML +//
+// Anzahl fragen: +// +// +// +//
+// +//
Frage
+// +// +// +//
+// +//
+// +// Du hast 2 von 3 Fragen richtig +// + + + diff --git a/uebung10/questions-show.php b/uebung10/questions-show.php new file mode 100644 index 0000000..6335d2e --- /dev/null +++ b/uebung10/questions-show.php @@ -0,0 +1,15 @@ +getQuestions($n); + +$questionsobj = json_encode($questions); +echo($questionobj); +?> diff --git a/uebung10/uebung-10.pdf b/uebung10/uebung-10.pdf new file mode 100644 index 0000000..00f92f2 Binary files /dev/null and b/uebung10/uebung-10.pdf differ diff --git a/uebung10/uebung10-examples/api.php b/uebung10/uebung10-examples/api.php new file mode 100644 index 0000000..05a92ea --- /dev/null +++ b/uebung10/uebung10-examples/api.php @@ -0,0 +1,60 @@ + $randomWeatherCondition, + "temperature" => $randomTemperature, + "img" => $randomWeatherCondition . ".png", + "certainty" => $certainty + ]; + +} + +/** + * Liefert ein Array mit assoziativen Arrays, die das Wetter zufällig "voraussagen" + * + * @param $n int Anzahl Tage, für die das Wetter vorausgesagt werden soll + * @return array + */ +function createRandomWeatherForNDays($n) +{ + $weatherForNDays = []; + + + for ($i = 0; $i < $n; $i++) { + $date = $tomorrow = date("d.m.Y", strtotime("+$i day")); + $weather = createRandomWeather(); + $weather['date'] = $date; + + $weatherForNDays[] = $weather; + } + + return $weatherForNDays; +} + +// Das Script liefert eine JSON-Ausgabe, setze daher den Content-Type auf application/json +header('Content-Type: application/json'); + +// Codiere das Array mit der Wettervorhersage in JSON und gib es aus +echo json_encode(createRandomWeatherForNDays(5)); \ No newline at end of file diff --git a/uebung10/uebung10-examples/img/cloudy.png b/uebung10/uebung10-examples/img/cloudy.png new file mode 100644 index 0000000..89351a3 Binary files /dev/null and b/uebung10/uebung10-examples/img/cloudy.png differ diff --git a/uebung10/uebung10-examples/img/rainy.png b/uebung10/uebung10-examples/img/rainy.png new file mode 100644 index 0000000..65842ef Binary files /dev/null and b/uebung10/uebung10-examples/img/rainy.png differ diff --git a/uebung10/uebung10-examples/img/snowy.png b/uebung10/uebung10-examples/img/snowy.png new file mode 100644 index 0000000..769c571 Binary files /dev/null and b/uebung10/uebung10-examples/img/snowy.png differ diff --git a/uebung10/uebung10-examples/img/stormy.png b/uebung10/uebung10-examples/img/stormy.png new file mode 100644 index 0000000..554f44f Binary files /dev/null and b/uebung10/uebung10-examples/img/stormy.png differ diff --git a/uebung10/uebung10-examples/img/sunny.png b/uebung10/uebung10-examples/img/sunny.png new file mode 100644 index 0000000..a24471a Binary files /dev/null and b/uebung10/uebung10-examples/img/sunny.png differ diff --git a/uebung10/uebung10-examples/img/windy.png b/uebung10/uebung10-examples/img/windy.png new file mode 100644 index 0000000..b2390f5 Binary files /dev/null and b/uebung10/uebung10-examples/img/windy.png differ diff --git a/uebung10/uebung10-examples/weather.html b/uebung10/uebung10-examples/weather.html new file mode 100644 index 0000000..a6c8eb6 --- /dev/null +++ b/uebung10/uebung10-examples/weather.html @@ -0,0 +1,177 @@ + + + + + Title + + + + + + + +

Das Wetter für Nirgendwo auf der Welt

+ +
Bitte warten
+ +

+ Das Wetter aktualisiert sich alle 15 Sekunden. Bereits 0 mal aktualisiert! +

+ +
+ +

+ © InTech-Wetter 2019, der zufälligste Wetterdienst der Welt + +

+ +
Icons made by Freepik from www.flaticon.com is + licensed by CC + 3.0 BY
+ + + + + + \ No newline at end of file