Results method is now GET and Dewey is displayed

This commit is contained in:
MatMasIt 2022-02-10 23:35:37 +01:00 committed by GitHub
parent 54a55fe363
commit 8a2f93b162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,108 +63,117 @@ function main($pdo, $pageN)
<div id="Demo1" class="w3-hide w3-container"> <div id="Demo1" class="w3-hide w3-container">
<?php <?php
$arrayQ = []; $arrayQ = [];
$mainQuery = "SELECT id,Titolo,Autore,ISBN FROM Libri WHERE "; $mainQuery = "SELECT id,Titolo,Autore,ISBN,Dewey FROM Libri WHERE ";
$lQuery = " SELECT DISTINCT upper(SUBSTR(Titolo,1,1)) AS letter FROM Libri ORDER BY letter"; $lQuery = " SELECT DISTINCT upper(SUBSTR(Titolo,1,1)) AS letter FROM Libri ORDER BY letter";
$query = ""; $query = "";
$flag = false; $flag = false;
if (!empty($_POST["Titolo"])) { if (!empty($_GET["Titolo"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Titolo)) LIKE ('%' || trim(lower(:Titolo)) || '%')"; $query .= " trim(lower(Titolo)) LIKE ('%' || trim(lower(:Titolo)) || '%')";
$arrayQ[":Titolo"] = $_POST["Titolo"]; $arrayQ[":Titolo"] = $_GET["Titolo"];
} }
if (!empty($_POST["Letter"])) { if (!empty($_GET["Letter"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Titolo)) LIKE ( trim(lower(:Letter)) || '%')"; $query .= " trim(lower(Titolo)) LIKE ( trim(lower(:Letter)) || '%')";
$arrayQ[":Letter"] = $_POST["Letter"]; $arrayQ[":Letter"] = $_GET["Letter"];
} }
if (!empty($_POST["Autore"])) { if (!empty($_GET["Autore"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Autore)) LIKE ('%' || trim(lower(:Autore)) || '%')"; $query .= " trim(lower(Autore)) LIKE ('%' || trim(lower(:Autore)) || '%')";
$arrayQ[":Autore"] = $_POST["Autore"]; $arrayQ[":Autore"] = $_GET["Autore"];
} }
if (!empty($_POST["Editore"])) { if (!empty($_GET["Editore"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Editore)) LIKE ('%' || trim(lower(:Editore)) || '%')"; $query .= " trim(lower(Editore)) LIKE ('%' || trim(lower(:Editore)) || '%')";
$arrayQ[":Editore"] = $_POST["Editore"]; $arrayQ[":Editore"] = $_GET["Editore"];
} }
if (!empty($_POST["Genere"])) { if (!empty($_GET["Genere"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Genere)) LIKE ('%' || trim(lower(:Genere)) || '%')"; $query .= " trim(lower(Genere)) LIKE ('%' || trim(lower(:Genere)) || '%')";
$arrayQ[":Genere"] = $_POST["Genere"]; $arrayQ[":Genere"] = $_GET["Genere"];
} }
if (!empty($_POST["ISBN"])) { if (!empty($_GET["ISBN"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(ISBN)) LIKE ('%' || trim(lower(:ISBN)) || '%')"; $query .= " trim(lower(ISBN)) LIKE ('%' || trim(lower(:ISBN)) || '%')";
$arrayQ[":ISBN"] = $_POST["ISBN"]; $arrayQ[":ISBN"] = $_GET["ISBN"];
} }
if (!empty($_POST["Inventario"])) { if (!empty($_GET["Inventario"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Inventario)) LIKE ('%' || trim(lower(:Inventario)) || '%')"; $query .= " trim(lower(Inventario)) LIKE ('%' || trim(lower(:Inventario)) || '%')";
$arrayQ[":Inventario"] = $_POST["Inventario"]; $arrayQ[":Inventario"] = $_GET["Inventario"];
} }
if (!empty($_POST["Serie"])) { if (!empty($_GET["Serie"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Serie)) LIKE ('%' || trim(lower(:Serie)) || '%')"; $query .= " trim(lower(Serie)) LIKE ('%' || trim(lower(:Serie)) || '%')";
$arrayQ[":Serie"] = $_POST["Serie"]; $arrayQ[":Serie"] = $_GET["Serie"];
} }
if (!empty($_POST["Lingua"])) { if (!empty($_GET["Lingua"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= "trim(lower(Lingua)) LIKE ('%' || trim(lower(:Lingua)) || '%')"; $query .= "trim(lower(Lingua)) LIKE ('%' || trim(lower(:Lingua)) || '%')";
$arrayQ[":Lingua"] = $_POST["Lingua"]; $arrayQ[":Lingua"] = $_GET["Lingua"];
}
if (!empty($_GET["Dewey"])) {
if (!$flag) {
$flag = true;
} else {
$query .= " AND ";
}
$query .= "trim(lower(Dewey)) LIKE ('%' || trim(lower(:Dewey)) || '%')";
$arrayQ[":Dewey"] = $_GET["Dewey"];
} }
if (!empty($_POST["Argomento"])) { if (!empty($_GET["Argomento"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " trim(lower(Argomento)) LIKE ('%' || trim(lower(:Argomento)) || '%')"; $query .= " trim(lower(Argomento)) LIKE ('%' || trim(lower(:Argomento)) || '%')";
$arrayQ[":Argomento"] = $_POST["Argomento"]; $arrayQ[":Argomento"] = $_GET["Argomento"];
} }
if ($_POST["Prestito"] == "P") { if ($_GET["Prestito"] == "P") {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " Prestito='P'"; $query .= " Prestito='P'";
} elseif ($_POST["Prestito"] == "NP") { } elseif ($_GET["Prestito"] == "NP") {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
@ -172,14 +181,14 @@ function main($pdo, $pageN)
} }
$query .= " Prestito!='P'"; $query .= " Prestito!='P'";
} }
if (!empty($_POST["NPag"])) { if (!empty($_GET["NPag"])) {
if (!$flag) { if (!$flag) {
$flag = true; $flag = true;
} else { } else {
$query .= " AND "; $query .= " AND ";
} }
$query .= " NPag =:NPag"; $query .= " NPag =:NPag";
$arrayQ[":NPag"] = $_POST["NPag"]; $arrayQ[":NPag"] = $_GET["NPag"];
} }
if (!$flag) $query .= " 1=1"; if (!$flag) $query .= " 1=1";
@ -196,7 +205,7 @@ function main($pdo, $pageN)
<div class="resultD w3-panel w3-card"> <div class="resultD w3-panel w3-card">
<?php <?php
$test = $_POST; $test = $_GET;
unset($test["Letter"]); unset($test["Letter"]);
unset($test["page"]); unset($test["page"]);
unset($test["first"]); unset($test["first"]);
@ -232,6 +241,9 @@ function main($pdo, $pageN)
<form method="POST" action="results.php"> <form method="POST" action="results.php">
<button class="w3-btn w3-left w3-orange"><i class="fa fa-book fa-fw w3-margin-right"></i>Sfoglia senza restrizioni</button> <button class="w3-btn w3-left w3-orange"><i class="fa fa-book fa-fw w3-margin-right"></i>Sfoglia senza restrizioni</button>
</form> </form>
<form method="POST" action="dewey.php">
<button class="w3-btn w3-left w3-blue-grey"><i class="fa fa-book fa-fw w3-margin-right"></i>Sfoglia catalogo dewey</button>
</form>
</div> </div>
<div class="resultD w3-panel w3-card"> <div class="resultD w3-panel w3-card">
<?php <?php
@ -247,9 +259,9 @@ function main($pdo, $pageN)
?> ?>
<form method="POST" style="display:inline;"> <form method="POST" style="display:inline;">
<?php <?php
$p = $_POST["page"]; $p = $_GET["page"];
unset($_POST["page"]); unset($_GET["page"]);
foreach ($_POST as $key => $val) { foreach ($_GET as $key => $val) {
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php ?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
} }
?> ?>
@ -257,7 +269,7 @@ function main($pdo, $pageN)
<button class="w3-btn w3-blue-grey"><?php echo htmlentities($letter); ?></button> <button class="w3-btn w3-blue-grey"><?php echo htmlentities($letter); ?></button>
</form> </form>
<?php <?php
$_POST["page"] = $p; $_GET["page"] = $p;
} }
?> ?>
</div> </div>
@ -288,6 +300,10 @@ function main($pdo, $pageN)
<th>ISBN</th> <th>ISBN</th>
<td><?php echo htmlentities(strlen(trim($data["ISBN"]))?$data["ISBN"]:"-"); ?></td> <td><?php echo htmlentities(strlen(trim($data["ISBN"]))?$data["ISBN"]:"-"); ?></td>
</tr> </tr>
<tr>
<th>Dewey</th>
<td><?php echo htmlentities(strlen(trim($data["Dewey"]))?$data["Dewey"]:"-"); ?></td>
</tr>
</table> </table>
<form action="bookDetail.php" method="GET" target="_blank"> <form action="bookDetail.php" method="GET" target="_blank">
<input name="id" type="hidden" value="<?php echo $data["id"]; ?>" /> <input name="id" type="hidden" value="<?php echo $data["id"]; ?>" />
@ -303,15 +319,15 @@ function main($pdo, $pageN)
?> ?>
<div class="w3-row"> <div class="w3-row">
<?php <?php
$p = (int)$_POST["page"]; $p = (int)$_GET["page"];
unset($_POST["page"]); unset($_GET["page"]);
if ($p != 0) { if ($p != 0) {
?> ?>
<div class="w3-third"> <div class="w3-third">
<form method="POST"> <form method="POST">
<?php <?php
foreach ($_POST as $key => $val) { foreach ($_GET as $key => $val) {
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php ?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
} }
?> ?>
@ -333,9 +349,9 @@ function main($pdo, $pageN)
<?php <?php
if ($i != 0 && $hasNewPage) { if ($i != 0 && $hasNewPage) {
?> ?>
<form method="POST"> <form method="GET">
<?php <?php
foreach ($_POST as $key => $val) { foreach ($_GET as $key => $val) {
?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php ?><input type="hidden" name="<?php echo htmlentities($key); ?>" value="<?php echo htmlentities($val); ?>" /><?php
} }
?> ?>
@ -416,5 +432,5 @@ function main($pdo, $pageN)
} }
$dbh = new PDO('sqlite:db'); $dbh = new PDO('sqlite:db');
main($dbh, $_POST["page"] ?: 0); main($dbh, $_GET["page"] ?: 0);
?> ?>