query("SELECT id, title, date(timestamp), author_sort, strftime('%Y',pubdate) AS pubyear, date(last_modified) FROM books WHERE id = '$ItemID'"); while ($row = $book->fetchArray()) { $row_id = $row['id']; $row_title = $row['title']; $row_created = $row['date(timestamp)']; $row_author_sort = $row['author_sort']; $row_pubdate = $row['pubyear']; $row_modified = $row['date(last_modified)']; } // ---------- Pull data from authors table ---------- $author = $db->query("SELECT name FROM authors INNER JOIN books_authors_link ON books_authors_link.author = authors.id WHERE books_authors_link.book = '$ItemID'"); while ($row = $author->fetchArray()) { $row_creator = $row['name']; } // ---------- Pull data from comments table ---------- $summary = $db->query("SELECT text FROM comments WHERE book = '$ItemID'"); while ($row = $summary->fetchArray()) { $row_summary = $row['text']; } // ---------- Pull data from publishers table ---------- $publisher = $db->query("SELECT name from publishers INNER JOIN books_publishers_link ON books_publishers_link.publisher = publishers.id WHERE books_publishers_link.book = '$ItemID'"); while ($row = $publisher->fetchArray()) { $row_publisher = $row['name']; } // ---------- Pull data from tags table ---------- $tags = $db->query("SELECT name FROM tags INNER JOIN books_tags_link ON books_tags_link.tag = tags.id WHERE tags.name NOT LIKE 'infopump%' AND books_tags_link.book = '$ItemID'"); // ---------- Pull data from tags table for Similar items ---------- /*$similartags = $db->query("SELECT name FROM tags INNER JOIN books_tags_link ON books_tags_link.tag = tags.id WHERE tags.name NOT LIKE 'infopump%' AND books_tags_link.book = '$ItemID' LIMIT 2");*/ // New similar tags query $similartags = $db->query("SELECT name FROM tags WHERE name IN (SELECT name FROM tags INNER JOIN books_tags_link ON books_tags_link.tag = tags.id AND books_tags_link.book = '$ItemID' ORDER BY RANDOM() LIMIT 2)"); $simtag = array(); while($row = $similartags->fetchArray()) { $simtag[] = $row['name']; } $getsimilar = $db->query("SELECT books.id, title, author_sort FROM books INNER JOIN books_tags_link ON books_tags_link.book = books.id INNER JOIN tags ON tags.id = books_tags_link.tag WHERE (tags.name LIKE '$simtag[0]' OR tags.name LIKE '$simtag[1]') AND books.id != '$ItemID' LIMIT 4"); // ---------- Pull data from identifiers table ---------- $identifiers = $db->query("SELECT type, val FROM identifiers WHERE book = '$ItemID'"); // ---------- Pull data from languages table ---------- $languages = $db->query("SELECT languages.lang_code AS lang_code FROM languages INNER JOIN books_languages_link ON books_languages_link.lang_code = languages.id WHERE book = '$ItemID' ORDER BY books_languages_link.item_order"); // ---------- Pull data from tags table to dertermine type ---------- $type = $db->query("SELECT custom_column_1.value AS itemtype FROM books_custom_column_1_link INNER JOIN custom_column_1 ON custom_column_1.id = books_custom_column_1_link.value WHERE books_custom_column_1_link.book = '$ItemID'"); while ($row = $type->fetchArray()) { $row_type = $row['itemtype']; } // -------------------- END DATABASE QUERIES -------------------- ?>
'; ?> ';?> '; ?> '; ?> '; ?> '; ?> '; ?> '; ?> '; ?> Item Record: '.$row_title.''; ?>