Erweiterte Suche funktioniert (Jahr fehlt)

master
Jasmin Weise 2023-06-02 13:17:12 +02:00
parent 86f191db5d
commit cbbfc06fdd
5 changed files with 98 additions and 44 deletions

View File

@ -34,38 +34,38 @@
<div class="hauptcontainer">
<span id="titelerweitertesuche" > Erweiterte Suche </span> <br><br>
<form action="erweiterte_suche.php" method="get">
<select name="select1" id="dropdown1" class="buchtitel">
<form action="suchergebnisse.php" method="get">
<select id="dropdown1" name="dropdown1" class="buchtitel">
<option selected="selected">Titel</option>
<option>Autor</option>
<option>Verlag</option>
<option>Stichwort</option>
</select>
<input type="search" class="buchtiteloptions">
<input type="search" name="search1" class="buchtiteloptions">
<select id="and_or" class="und-wort1">
<select id="and_or" name="and_or1" class="und-wort1">
<option>und</option>
<option>oder</option>
</select>
<select id="dropdown2" class="autor">
<select id="dropdown2" name="dropdown2" class="autor">
<option>Titel</option>
<option selected="selected">Autor</option>
<option>Verlag</option>
<option>Stichwort</option>
</select>
<input type="search" class="autoroptions">
<input type="search" name="search2" class="autoroptions">
<select id="and_or" class="und-wort2">
<select id="and_or" name="and_or2" class="und-wort2">
<option>und</option>
<option>oder</option>
</select>
<select id="dropdown3" class="stichwort">
<select id="dropdown3" name="dropdown3" class="stichwort">
<option>Titel</option>
<option>Autor</option>
<option>Verlag</option>
<option selected="selected">Stichwort</option>
</select>
<input type="search" class="stichwörteroptions">
<input type="search" name="search3" class="stichwörteroptions">
<span id="weiteresuchkriterien" style> Weitere Suchkriterien</span><br><br></p>
<span class="jahrvon">Jahr von </span>
@ -73,19 +73,13 @@
<span class="bis">bis </span>
<input type="date" class="endsdatum" name="Buchdatum2">
<span class="sprache">Sprache </span>
<select id="language" class="spracheingabe">
<select id="language" name="language" class="spracheingabe">
<option>Alle Sprachen</option>
<option>Deutsch</option>
<option>Englisch</option>
<option>Französisch</option>
<option>Arabisch</option>
</select>
<datalist id="sprachoptionen">
<option value="Deutsch"></option>
<option value="Englisch"></option>
<option value="Arabisch"></option>
<option value="Französisch"></option>
</datalist>
<span class="verfügbarkeit">Verfügbarkeit</span>
<input type="checkbox" class="checkbox" name="status" value="verfügbareBücher">
<span class="kommentar">verfügbare Bücher</span>

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

View File

@ -428,6 +428,7 @@ body{
text-decoration: none;
border-radius: 8px;
border: none;
cursor: pointer;
}

View File

@ -4,15 +4,15 @@
.hauptcontainer {
/*Einzelne Elemente untereinander anzeigen.*/
flex-direction: column;
height: 71%;
}
#searchResult_heading {
background-color: #70AD47;
/* background-color: #70AD47; */
margin-top: 30px;
margin-left: 30px;
margin-bottom: 25px;
margin-right: 50px;
font-weight: 500;
}
/*Container wird mit Daten aus der Datenbank gefüllt.*/
@ -23,17 +23,17 @@
}
.book_container {
background-color: blueviolet;
/* background-color: blueviolet; */
display: flex;
/*Einzelne Elemente nebeneinander anzeigen.*/
flex-direction: row;
}
.bookCover_container {
background-color: blue;
/*background-color: blue;*/
display: flex;
/*Verbietet dem Container, seine Standardgröße (px) zu ändern.*/
flex: 0 0 125px;
flex: 0 0 150px;
align-items: center;
height: auto;
}
@ -45,12 +45,21 @@
}
.bookDetails_container {
background-color: aquamarine;
/* background-color: aquamarine; */
width: 100%;
display: flex;
flex-direction: column;
padding-left: 25px;
padding-right: 25px;
padding-left: 15px;
padding-right: 15px;
}
.bookTitle {
margin-bottom: 10px;
font-weight: 400;
}
.bookDetails {
margin-bottom: 10px;
}
.available_container {
@ -68,7 +77,7 @@
}
.shoppingCart_container {
background-color: chartreuse;
/* background-color: chartreuse; */
margin-left: auto;
margin-top: auto;
flex: 0 0 40px;

View File

@ -36,13 +36,70 @@
<!------------------------------------------------------------------------->
<div class="hauptcontainer">
<form action="su">
</form>
<h1 id="searchResult_heading">Suchergebnisse</h1>
<div id="searchResult_container">
<?php
/* Eingegebene Daten in Variablen speichern */
$dropdown1 = $_GET['dropdown1'];
$search1 = $_GET['search1'];
$andOr1 = $_GET['and_or1'];
if ($andOr1 == 'und') {
$andOr1 = 'AND';
}
else {
$andOr1 = 'OR';
}
$dropdown2 = $_GET['dropdown2'];
$search2 = $_GET['search2'];
$andOr2 = $_GET['and_or2'];
if ($andOr2 == 'und') {
$andOr2 = 'AND';
}
else {
$andOr2 = 'OR';
}
$dropdown3 = $_GET['dropdown3'];
$search3 = $_GET['search3'];
/* TODO: Datum/Jahr */
$language = $_GET['language'];
if ($language == 'Alle Sprachen') {
$language = '%%';
}
$available = isset($_GET['status']);
if ($available) {
$available = 'Verfügbar';
}
else {
$available = '%%';
}
/* SQL-Befehl zusammenstellen */
$sql = "SELECT b.BuchID, b.Titel, b.Erscheinungsjahr, b.Bild,
b.Verlag, GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName) SEPARATOR ', ') AS 'Autor',
GROUP_CONCAT(DISTINCT k.Name SEPARATOR ', ') AS 'Kategorie',
b.ISBN, b.Klappentext AS 'Inhalt', sp.Bezeichnung AS 'Sprache',
GROUP_CONCAT(DISTINCT st.Text SEPARATOR ', ') AS 'Stichwort',
IF(b.Anzahl!=0, 'Verfügbar', CONCAT('Verfügbar ab: ', 'Test!')) 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
HAVING $dropdown1 LIKE '%$search1%'
$andOr1 $dropdown2 LIKE '%$search2%'
$andOr2 $dropdown3 LIKE '%$search3%'
AND Sprache LIKE '$language'
AND Verfügbarkeit LIKE '$available';";
$servername = "localhost";
$username = "web_b-3";
$password = "een7Ao6s";
@ -54,15 +111,6 @@
die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
}
$sql = "SELECT b.BuchID, b.Titel, b.Erscheinungsjahr, b.Bild,
b.Verlag, GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName) SEPARATOR ', ') AS 'Autor',
GROUP_CONCAT(DISTINCT k.Name SEPARATOR ', ') AS 'Kategorie',
IF(b.Anzahl!=0, 'Verfügbar', 'Verfügbar ab: ') 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
GROUP BY b.BuchID";
$result = mysqli_query($connection, $sql);
$counter = 0;
if (mysqli_num_rows($result) > 0) {
@ -82,20 +130,22 @@
echo "<div class='book_container'>
<div class='bookCover_container'>
<img class=bookCover' src='$bookCover' alt='fehler'>
<img class='bookCover' src='pictures/$bookCover' alt='Kein Bild vorhanden'>
</div>
<div class='bookDetails_container'>
<h2 class='bookTitle'>$bookTitle</h2>
<p class='author'>Verfasser: $bookAuthor</p>
<p class='publishing_year'>Erscheinungsjahr: $bookPublishingYear</p>
<p class='publisher'>Verlag: $bookPublisher</p>
<p class='category'>Kategorie: $bookCategory</p>
<div class='bookDetails'>
<p class='author'>Verfasser: $bookAuthor</p>
<p class='publishing_year'>Erscheinungsjahr: $bookPublishingYear</p>
<p class='publisher'>Verlag: $bookPublisher</p>
<p class='category'>Kategorie: $bookCategory</p>
</div>
<div class='available_container'>
<p id='$bookID' class='available'>$bookAvailability</p>
<p id='available_$bookID' class='available'>$bookAvailability</p>
<!--TODO: Auslagern-->
<script type='text/javascript' language='JavaScript'>
(function() {
var currentElement = document.getElementById('$bookID');
var currentElement = document.getElementById('available_$bookID');
var parentDiv = currentElement.parentElement;
if (currentElement.innerHTML == 'Verfügbar') {
parentDiv.style.backgroundColor = '#70AD47';