From edecc52eb02201b9ac18287a3947d3e2b2f939dd Mon Sep 17 00:00:00 2001 From: Sebastian Greil <2123300@stud.hs-mannheim.de> Date: Sun, 11 Jun 2023 12:00:38 +0200 Subject: [PATCH] meinebuecher stand 11.06 --- meinebuecher.php | 225 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 171 insertions(+), 54 deletions(-) diff --git a/meinebuecher.php b/meinebuecher.php index 9aaa8bf..f7cd986 100644 --- a/meinebuecher.php +++ b/meinebuecher.php @@ -1,4 +1,3 @@ - 0){ - - $_SESSION['eingeloggt'] = 1; - echo ' + + if($row['COUNT(*)'] > 0){ + + $_SESSION['eingeloggt'] = 1; + echo ' + + Candle Bibliothek | Meine Bücher - + -
-

Meine Bücher

- -
- - - - - - - - - - - - - - - - '; + +
+

Meine Bücher

+
'; - }else if($zeile['COUNT(*)'] > 0){ - header("Location: passwort_stimmt_nicht.html"); - }else{ - header("Location: benutzer_existiert_nicht.html"); + $sql = "SELECT b.BuchID, b.Titel, b.Bild, + GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName) + SEPARATOR ', ') AS 'Autor', + IF(b.Anzahl!=0, 'Verfügbar', CONCAT('Verfügbar ab: ', + (SELECT DATE_FORMAT(DATE_ADD(ab.Enddatum, INTERVAL 1 DAY) + ,'%d.%m.%Y') FROM `ausgeliehenes_buch` AS ab + WHERE ab.BuchID = b.BuchID + ORDER BY ab.Reserviert ASC, ab.Enddatum ASC LIMIT 1))) + AS 'Verfügbarkeit' FROM `buch` AS b + INNER JOIN `buch_verfasst_von_autor` AS bvva + ON b.BuchID = bvva.BuchID + INNER JOIN `autor` AS a ON bvva.AutorNr = a.AutorNr + INNER JOIN `buch_hat_kategorie` AS bhk ON bhk.BuchID = b.BuchID + INNER JOIN `kategorie` AS k ON k.KategorieID = bhk.KategorieID + INNER JOIN `sprache` AS sp ON sp.SprachenID = b.SprachenID + INNER JOIN `buch_hat_stichwort` AS bhs ON bhs.BuchID = b.BuchID + INNER JOIN `stichwort` AS st ON st.StichwortID = bhs.StichwortID + GROUP BY b.BuchID + ;"; + + $servername = "localhost"; + $username = "web_b-3"; + $password = "een7Ao6s"; + $dbname = "bibliothek_candle"; + + $connection = mysqli_connect($servername, $username, $password, $dbname); + + if (!$connection) { + die("Verbindung fehlgeschlagen: " . mysqli_connect_error()); } - }else{ + + $result = mysqli_query($connection, $sql); + + $counter = 0; + if (mysqli_num_rows($result) > 0) { + while($row = mysqli_fetch_assoc($result)) { + $bookID = $row['BuchID']; + $bookCover = $row['Bild']; + $bookTitle = $row['Titel']; + $bookAuthor = $row['Autor']; + $bookAvailability = $row['Verfügbarkeit']; + + if ($counter != 0) { + echo "
"; + } + // TODO: OnClick auslagern. + echo "
+
+ Kein Bild vorhanden +
+
+

$bookTitle

+
+

von $bookAuthor

+ +
+
+

+ $bookAvailability

+ + +
+
+ +

Helloooo

+ +
+
+
+
+
+
"; + $counter++; + } + } else { + echo "Keine Ergebnisse."; + } + + if (!$result) { + die("Ungültige SQL-Abfrage: " . mysqli_connect_error()); + } + + mysqli_close($connection); + + + }else if($zeile['COUNT(*)'] > 0){ + header("Location: passwort_stimmt_nicht.html"); + }else{ + header("Location: benutzer_existiert_nicht.html"); + } +}else{ header("Location: 404.html"); - } - +} + ?> + +
+
+ + + + + + + + + + + + + + \ No newline at end of file