letter ordering, no nextpage on void content

This commit is contained in:
MatMasIt 2022-02-04 11:35:08 +01:00 committed by GitHub
parent 583e0d1bcc
commit 23a9a1d074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
<?php <?php
require("common.php"); require("common.php");
require("isbnImage.php"); //require("isbnImage.php");
function main($pdo, $pageN) function main($pdo, $pageN)
{ {
@ -59,12 +59,12 @@ function main($pdo, $pageN)
<div class="w3-card w3-round"> <div class="w3-card w3-round">
<div class="w3-white"> <div class="w3-white">
<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-list fa-fw w3-margin-right"></i>Risultati dell'interrogazione</button> <button onclick="myFunction('Demo1')" class="w3-button w3-block w3-theme-l1 w3-left-align"><i class="fa fa-list fa-fw w3-margin-right"></i>Risultati dell&apos;interrogazione</button>
<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 FROM Libri WHERE ";
$lQuery = " SELECT DISTINCT upper(SUBSTR(Titolo,1,1)) AS letter FROM Libri"; $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($_POST["Titolo"])) {
@ -184,10 +184,14 @@ function main($pdo, $pageN)
if (!$flag) $query .= " 1=1"; if (!$flag) $query .= " 1=1";
$query .= " ORDER BY Titolo ASC"; $query .= " ORDER BY Titolo ASC";
$newPage = $mainQuery.$query." LIMIT 10 OFFSET ".(($pageN+1)*10);
$query .= " LIMIT " . (10) . " OFFSET " . ($pageN * 10); $query .= " LIMIT " . (10) . " OFFSET " . ($pageN * 10);
$mainQuery .= $query; $mainQuery .= $query;
$stmt = $pdo->prepare($lQuery); $stmt = $pdo->prepare($lQuery);
$stmt->execute(); $stmt->execute();
$np = $pdo->prepare($newPage);
$np->execute($arrayQ);
$hasNewPage = count($np->fetchAll()) > 0;
?> ?>
<div class="resultD w3-panel w3-card"> <div class="resultD w3-panel w3-card">
@ -268,7 +272,9 @@ function main($pdo, $pageN)
} }
?> ?>
<div class="resultD w3-panel w3-card"> <div class="resultD w3-panel w3-card">
<img src="<?php echo isbnImage($data["ISBN"]); ?>" style="width:10vw;" /> <!-- <img src="<?php
//echo isbnImage($data["ISBN"]);
?>books.png" style="width:10vw;" /> --->
<table> <table>
<tr> <tr>
<th>Titolo</th> <th>Titolo</th>
@ -280,10 +286,10 @@ function main($pdo, $pageN)
</tr> </tr>
<tr> <tr>
<th>ISBN</th> <th>ISBN</th>
<td><?php echo htmlentities($data["ISBN"]); ?></td> <td><?php echo htmlentities(strlen(trim($data["ISBN"]))?$data["ISBN"]:"-"); ?></td>
</tr> </tr>
</table> </table>
<form action="bookDetail.php" method="GET"> <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"]; ?>" />
<button class="w3-btn w3-right w3-blue-grey"><i class="fa fa-arrow-circle-right fa-fw w3-margin-right"></i>Vedi</button> <button class="w3-btn w3-right w3-blue-grey"><i class="fa fa-arrow-circle-right fa-fw w3-margin-right"></i>Vedi</button>
</form> </form>
@ -325,7 +331,7 @@ function main($pdo, $pageN)
</div> </div>
<div class="w3-third"> <div class="w3-third">
<?php <?php
if ($i != 0) { if ($i != 0 && $hasNewPage) {
?> ?>
<form method="POST"> <form method="POST">
<?php <?php