diff --git a/results.php b/results.php index 5b380db..1202ca1 100644 --- a/results.php +++ b/results.php @@ -5,22 +5,27 @@ include_once "settings.php"; // Get and use a basic title search for pulling records. $keywordsearch = htmlspecialchars($_GET["kw"]); $authorsearch = htmlspecialchars($_GET["au"]); +$typesearch = htmlspecialchars($_GET["ty"]); $socialkw = mb_convert_case($keywordsearch, MB_CASE_TITLE, "UTF-8"); $socialau = mb_convert_case($authorsearch, MB_CASE_TITLE, "UTF-8"); +$socialty = mb_convert_case($typesearch, MB_CASE_TITLE, "UTF-8"); -if (empty($keywordsearch)) { +if (!empty($keywordsearch)) { + $searchtopic = $socialkw; +} elseif (!empty($authorsearch)) { $searchtopic = $socialau; } else { - $searchtopic = $socialkw; + $searchtopic = 'Type: '.$socialty; } + // -------------------- BEGIN DATABASE QUERIES -------------------- // Establish atabase connection $db = new SQLite3('metadata.sqlite'); -$titlequery = $db->query("SELECT +$keywordquery = $db->query("SELECT DISTINCT books.id AS id, books.title AS title, SUBSTR(comments.text,0,120) AS excerpt @@ -46,11 +51,23 @@ INNER JOIN comments ON comments.book = books.id INNER JOIN books_tags_link ON books_tags_link.book = books.id -INNER JOIN -tags ON tags.id = books_tags_link.tag WHERE books.author_sort LIKE '%$authorsearch%' ORDER BY books.title ASC"); +$typequery = $db->query("SELECT +DISTINCT books.id AS id, +books.title AS title, +SUBSTR(comments.text,0,120) AS excerpt +FROM books +INNER JOIN +comments ON comments.book = books.id +INNER JOIN +books_custom_column_1_link ON books_custom_column_1_link.book = books.id +INNER JOIN +custom_column_1 ON custom_column_1.id = books_custom_column_1_link.value +WHERE +custom_column_1.value = '$typesearch' +ORDER BY books.title ASC"); ?> @@ -189,7 +206,7 @@ ORDER BY books.title ASC");
  • -->
    -

    Search Results:

    +

    Search Results -

    @@ -206,13 +223,21 @@ ORDER BY books.title ASC");
    fetchArray()) { + while ($row = $keywordquery->fetchArray()) { $row_id = $row['id']; $row_title = $row['title']; $row_excerpt = $row['excerpt']; echo '

    '.$row_title.' : '.strip_tags($row_excerpt).'...

    '; } + } elseif ($typesearch != '') { + while ($row = $typequery->fetchArray()) { + $row_id = $row['id']; + $row_title = $row['title']; + $row_excerpt = $row['excerpt']; + + echo '

    '.$row_title.' : '.strip_tags($row_excerpt).'...

    '; + } } else { while ($row = $authorquery->fetchArray()) { $row_id = $row['id'];