Suchergebnisse Erweiterte Suche

Es fehlt: Verfügbar ab...
master
Jasmin Weise 2023-06-02 21:06:56 +02:00
parent 8fc8c48414
commit 2730d10153
2 changed files with 66 additions and 20 deletions

View File

@ -27,6 +27,7 @@
display: flex; display: flex;
/*Einzelne Elemente nebeneinander anzeigen.*/ /*Einzelne Elemente nebeneinander anzeigen.*/
flex-direction: row; flex-direction: row;
cursor: pointer;
} }
.bookCover_container { .bookCover_container {

View File

@ -64,7 +64,24 @@
$dropdown3 = $_GET['dropdown3']; $dropdown3 = $_GET['dropdown3'];
$search3 = $_GET['search3']; $search3 = $_GET['search3'];
/* TODO: Datum/Jahr */ $startYear = $_GET['Buchdatum1'];
$startYear = substr($startYear, 0, 4);
$endYear = $_GET['Buchdatum2'];
$endYear = substr($endYear, 0, 4);
$yearQuery = '';
/* Nur Startjahr */
if ($startYear && !$endYear) {
$yearQuery = "WHERE b.Erscheinungsjahr > $startYear";
}
/* Nur Endjahr */
else if (!$startYear && $endYear) {
$yearQuery = "WHERE b.Erscheinungsjahr < $endYear";
}
/* Start- und Endjahr */
else if ($startYear && $endYear) {
$yearQuery =
"WHERE b.Erscheinungsjahr BETWEEN $startYear AND $endYear";
}
$language = $_GET['language']; $language = $_GET['language'];
if ($language == 'Alle Sprachen') { if ($language == 'Alle Sprachen') {
@ -81,18 +98,22 @@
/* SQL-Befehl zusammenstellen */ /* SQL-Befehl zusammenstellen */
$sql = "SELECT b.BuchID, b.Titel, b.Erscheinungsjahr, b.Bild, $sql = "SELECT b.BuchID, b.Titel, b.Erscheinungsjahr, b.Bild,
b.Verlag, GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName) SEPARATOR ', ') AS 'Autor', b.Verlag, GROUP_CONCAT(DISTINCT CONCAT(a.VorName, ' ', a.NachName)
SEPARATOR ', ') AS 'Autor',
GROUP_CONCAT(DISTINCT k.Name SEPARATOR ', ') AS 'Kategorie', GROUP_CONCAT(DISTINCT k.Name SEPARATOR ', ') AS 'Kategorie',
b.ISBN, b.Klappentext AS 'Inhalt', sp.Bezeichnung AS 'Sprache', b.ISBN, b.Klappentext AS 'Inhalt', sp.Bezeichnung AS 'Sprache',
GROUP_CONCAT(DISTINCT st.Text SEPARATOR ', ') AS 'Stichwort', 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 IF(b.Anzahl!=0, 'Verfügbar', CONCAT('Verfügbar ab: ', 'Test!'))
INNER JOIN `buch_verfasst_von_autor` AS bvva ON b.BuchID = bvva.BuchID 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 `autor` AS a ON bvva.AutorNr = a.AutorNr
INNER JOIN `buch_hat_kategorie` AS bhk ON bhk.BuchID = b.BuchID INNER JOIN `buch_hat_kategorie` AS bhk ON bhk.BuchID = b.BuchID
INNER JOIN `kategorie` AS k ON k.KategorieID = bhk.KategorieID INNER JOIN `kategorie` AS k ON k.KategorieID = bhk.KategorieID
INNER JOIN `sprache` AS sp ON sp.SprachenID = b.SprachenID INNER JOIN `sprache` AS sp ON sp.SprachenID = b.SprachenID
INNER JOIN `buch_hat_stichwort` AS bhs ON bhs.BuchID = b.BuchID INNER JOIN `buch_hat_stichwort` AS bhs ON bhs.BuchID = b.BuchID
INNER JOIN `stichwort` AS st ON st.StichwortID = bhs.StichwortID INNER JOIN `stichwort` AS st ON st.StichwortID = bhs.StichwortID
$yearQuery
GROUP BY b.BuchID GROUP BY b.BuchID
HAVING $dropdown1 LIKE '%$search1%' HAVING $dropdown1 LIKE '%$search1%'
$andOr1 $dropdown2 LIKE '%$search2%' $andOr1 $dropdown2 LIKE '%$search2%'
@ -105,7 +126,8 @@
$password = "een7Ao6s"; $password = "een7Ao6s";
$dbname = "bibliothek_candle"; $dbname = "bibliothek_candle";
$connection = mysqli_connect($servername, $username, $password, $dbname); $connection =
mysqli_connect($servername, $username, $password, $dbname);
if (!$connection) { if (!$connection) {
die("Verbindung fehlgeschlagen: " . mysqli_connect_error()); die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
@ -127,31 +149,43 @@
if ($counter != 0) { if ($counter != 0) {
echo "<div class='divider'></div>"; echo "<div class='divider'></div>";
} }
/* TODO: OnClick auslagern. */
echo "<div class='book_container'> echo "<div id='book_container$bookID' class='book_container'
onclick='open_bookDetails(this.id)'>
<div class='bookCover_container'> <div class='bookCover_container'>
<img class='bookCover' src='pictures/$bookCover' alt='Kein Bild vorhanden'> <img class='bookCover' src='pictures/$bookCover'
alt='Kein Bild vorhanden'>
</div> </div>
<div class='bookDetails_container'> <div class='bookDetails_container'>
<h2 class='bookTitle'>$bookTitle</h2> <h2 class='bookTitle'>$bookTitle</h2>
<div class='bookDetails'> <div class='bookDetails'>
<p class='author'>Verfasser: $bookAuthor</p> <p class='author'>Verfasser: $bookAuthor</p>
<p class='publishing_year'>Erscheinungsjahr: $bookPublishingYear</p> <p class='publishing_year'>
<p class='publisher'>Verlag: $bookPublisher</p> Erscheinungsjahr: $bookPublishingYear</p>
<p class='category'>Kategorie: $bookCategory</p> <p class='publisher'>
Verlag: $bookPublisher</p>
<p class='category'>
Kategorie: $bookCategory</p>
</div> </div>
<div class='available_container'> <div class='available_container'>
<p id='available_$bookID' class='available'>$bookAvailability</p> <p id='available_$bookID' class='available'>
$bookAvailability</p>
<!--TODO: Auslagern--> <!--TODO: Auslagern-->
<script type='text/javascript' language='JavaScript'> <script type='text/javascript'
language='JavaScript'>
(function() { (function() {
var currentElement = document.getElementById('available_$bookID'); var currentElement = document.
var parentDiv = currentElement.parentElement; getElementById('available_$bookID');
if (currentElement.innerHTML == 'Verfügbar') { var parentDiv =
parentDiv.style.backgroundColor = '#70AD47'; currentElement.parentElement;
if (currentElement.innerHTML.trim()
== 'Verfügbar') {
parentDiv.style.backgroundColor
= '#70AD47';
} }
else { else {
parentDiv.style.backgroundColor = '#F34343'; parentDiv.style.backgroundColor
= '#F34343';
} }
})(); })();
</script> </script>
@ -173,12 +207,23 @@
mysqli_close($connection); mysqli_close($connection);
?> ?>
</div> </div>
</div> </div>
<!------------------------------------------------------------------------->
<script>
function open_bookDetails(ID) {
var data = new URLSearchParams();
data.append("bookID", ID);
var url = "http://141.19.142.11/buch_details.php?" +
data.toString();
location.href = url;
}
</script>
<!-------------------------------------------------------------------------> <!------------------------------------------------------------------------->
<!--Link JS file--> <!--Link JS file-->