diff --git a/warenkorb.php b/warenkorb.php index b894de0..38c70d9 100644 --- a/warenkorb.php +++ b/warenkorb.php @@ -1,95 +1,317 @@ + + - - + + + + + + + + Candle Bibliothek | Warenkorb + + + + + -session_start(); -$db_link = mysqli_connect('localhost', 'web_b-3', 'een7Ao6s', 'bibliothek_candle', '3306'); - - function runSQL($sql){ - global $db_link; - $db_res = mysqli_query($db_link, $sql); - if(!$db_res){ - header("Location: 404.html"); - exit; - } - return $db_res; -} + - if(isset($_POST['submit'])){ - $kartenid = $_POST['karten-id']; - $passwort = $_POST['password']; +
+

Warenkorb

+
+
+ $item) { + + $quantity = $item['quantity']; - if($row['COUNT(*)'] > 0){ - - $_SESSION['eingeloggt'] = 1; + $sql = ''; - echo ' - - - - - - - Candle Bibliothek | Warenkorb - - - - - - - - -
-

- Warenkorb -

- -
- - - - - -
- - - -
- - - - - - -
- - - '; - }else if($zeile['COUNT(*)'] > 0){ - header("Location: passwort_stimmt_nicht.php"); - }else{ - header("Location: benutzer_existiert_nicht.php"); - } - }else{ - header("Location: 404.html"); - } + $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()); + } + + /* SQL-Befehl vorbereiten */ + $sql = $connection->prepare("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 + WHERE b.BuchID = ? + GROUP BY b.BuchID;"); + + // Parameter binden + $sql->bind_param("i", $ID); + + // ID festlegen + $ID = $key; + + // SQL-Befehl ausführen + $sql->execute(); + + // Ergebnis speichern + $result = $sql->get_result(); + + if ($counter != 0) { + echo "
"; + } + 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']; + + // TODO: OnClick auslagern. + echo "
+
+ Kein Bild vorhanden +
+
+

$bookTitle

+
+

von $bookAuthor

+
+
+

+ $bookAvailability

+ + +
+
+ +
+
+
+
+
+

$quantity

+
+
+
+
+
+
+
+
+
"; + $counter++; + } + } else { + echo "Keine Ergebnisse."; + } + + if (!$result) { + die("Ungültige SQL-Abfrage: " . mysqli_connect_error()); + } + + mysqli_close($connection); + + $counter++; + } + } + else { + // Es liegen keine Bücher im Warenkorb + echo + "Der Warenkorb ist leer, + bitte fügen Sie Bücher hinzu."; + } + + ?> + +
+
+
+

? Artikel

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + +