Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>test applikation</title>
- </head>
- <body>
- <h1>Hallo Student</h1>
- <form>
- Matrikel:<br>
- <input type="text" name="matrikel"><br>
- <input type="submit" value="Submit">
- </form>
- <?php
- function durchschnitt(array $notes) {
- $Anzahl = count($notes);
- $Summe = 0.0;
- $i = 0;
- while ($i < $Anzahl) {
- $Summe = $Summe + $notes[$i];
- $i = $i + 1;
- }
- $Durchschnitt = $Summe / $Anzahl;
- return $Durchschnitt;
- }
- if (is_int((int) $_GET['matrikel'])) {
- $matrikel = $_GET['matrikel'];
- $Noten = array();
- $link = new mysqli('localhost', 'notenapp', 'start123', 'notenapp');
- $result = $link->query("SELECT note.wert as wert, kurs.name as name FROM note, kurs, student WHERE note.kurs_id = kurs.id AND note.student_id = student.id AND student.matrikel = '$matrikel'");
- while ($row = $result->fetch_row()) {
- $note = $row[0];
- $Noten[] = $note;
- $name = $row[1];
- echo "<p>$name: $note</p>";
- }
- /* $Noten = array(1.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0); */
- echo "<p><strong>" . date('Y-m-d i:s') . "</strong></p>";
- echo "<p><strong>" . durchschnitt($Noten) . "</strong></p>";
- if (count($Noten) == 0) {
- echo "<p><strong>Sie haben keine Noten.<strong></p>";
- } elseif (durchschnitt($Noten) > 4) {
- echo "<p><strong>Sie haben nicht bestanden! (Sorry :-( )<strong></p>";
- } else {
- echo "<p><strong>Sie haben bestanden! :-)<strong></p>";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement