Added keyword searching.

This commit is contained in:
2023-07-19 21:06:43 -05:00
parent 28524a107d
commit 5601c54460
2 changed files with 11 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
// Get and use a basic title search for pulling records. // Get and use a basic title search for pulling records.
$titlesearch = htmlspecialchars($_GET["titlesearch"]); $keywordsearch = htmlspecialchars($_GET["kw"]);
// -------------------- BEGIN DATABASE QUERIES -------------------- // -------------------- BEGIN DATABASE QUERIES --------------------
@ -9,13 +9,20 @@ $titlesearch = htmlspecialchars($_GET["titlesearch"]);
$db = new SQLite3('metadata.sqlite'); $db = new SQLite3('metadata.sqlite');
$titlequery = $db->query("SELECT $titlequery = $db->query("SELECT
books.id AS id, DISTINCT books.id AS id,
books.title AS title, books.title AS title,
SUBSTR(comments.text,0,120) AS excerpt SUBSTR(comments.text,0,120) AS excerpt
FROM books FROM books
INNER JOIN INNER JOIN
comments ON comments.book = books.id comments ON comments.book = books.id
WHERE books.title LIKE '%$titlesearch%' INNER JOIN
books_tags_link ON books_tags_link.book = books.id
INNER JOIN
tags ON tags.id = books_tags_link.tag
WHERE books.title LIKE '%$keywordsearch%'
OR books.author_sort LIKE '%$keywordsearch%'
OR comments.text LIKE '%$keywordsearch%'
OR tags.name LIKE '%$keywordsearch%'
ORDER BY books.title ASC"); ORDER BY books.title ASC");
?> ?>

View File

@ -119,7 +119,7 @@ LIMIT 4');
<h3 class="heading">Search</h3> <h3 class="heading">Search</h3>
<form action="basictitlesearch.php" method="get"> <form action="basictitlesearch.php" method="get">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" name="titlesearch" placeholder="Basic title search"> <input type="text" class="form-control" name="kw" placeholder="Keyword search">
</div> </div>
</form> </form>
</div> </div>