Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>test applikation</title>
  4. </head>
  5. <body>
  6. <h1>Hallo Student</h1>
  7.  
  8. <form>
  9. Matrikel:<br>
  10. <input type="text" name="matrikel"><br>
  11. <input type="submit" value="Submit">
  12. </form>
  13. <?php
  14.  
  15. function durchschnitt(array $notes) {
  16. $Anzahl = count($notes);
  17. $Summe = 0.0;
  18. $i = 0;
  19. while ($i < $Anzahl) {
  20. $Summe = $Summe + $notes[$i];
  21. $i = $i + 1;
  22. }
  23. $Durchschnitt = $Summe / $Anzahl;
  24. return $Durchschnitt;
  25. }
  26.  
  27. if (is_int((int) $_GET['matrikel'])) {
  28. $matrikel = $_GET['matrikel'];
  29. $Noten = array();
  30. $link = new mysqli('localhost', 'notenapp', 'start123', 'notenapp');
  31. $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'");
  32. while ($row = $result->fetch_row()) {
  33. $note = $row[0];
  34. $Noten[] = $note;
  35. $name = $row[1];
  36. echo "<p>$name: $note</p>";
  37. }
  38.  
  39. /* $Noten = array(1.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0); */
  40.  
  41. echo "<p><strong>" . date('Y-m-d i:s') . "</strong></p>";
  42. echo "<p><strong>" . durchschnitt($Noten) . "</strong></p>";
  43.  
  44. if (count($Noten) == 0) {
  45. echo "<p><strong>Sie haben keine Noten.<strong></p>";
  46. } elseif (durchschnitt($Noten) > 4) {
  47. echo "<p><strong>Sie haben nicht bestanden! (Sorry :-( )<strong></p>";
  48. } else {
  49. echo "<p><strong>Sie haben bestanden! :-)<strong></p>";
  50. }
  51. }
  52. ?>
  53.  
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement