diff --git a/data.sample.db b/data.sample.db index 74fddb0..b288229 100644 Binary files a/data.sample.db and b/data.sample.db differ diff --git a/index.php b/index.php index 4e34002..91f38ff 100644 --- a/index.php +++ b/index.php @@ -6,16 +6,18 @@ set_time_limit(-1); $db = new SQLite3('data.db'); - -$stmt = $db->prepare('SELECT * FROM book '); +if (isset($_GET['category']) && strlen($_GET['category'])) { + $stmt = $db->prepare('SELECT * FROM book WHERE category_slug = :category_slug'); + $stmt->bindValue(':category_slug', $_GET['category'], SQLITE3_TEXT); +} else { + $stmt = $db->prepare('SELECT * FROM book '); +} //$stmt->bindValue(':nid', $bookData['nid'], SQLITE3_INTEGER); $result = $stmt->execute(); -echo '
';
 
 echo '';
 print('');
 while ($resultArray = $result->fetchArray(SQLITE3_ASSOC)) {
-//    print_r($resultArray);
 
     $pdfUrl = 'books/' . $resultArray['nid'] . '/' . $resultArray['nid'] . '.pdf';
     $epubUrl = 'books/' . $resultArray['nid'] . '/' . $resultArray['nid'] . '.epub';
@@ -25,8 +27,8 @@ while ($resultArray = $result->fetchArray(SQLITE3_ASSOC)) {
         $codeId = $found[0];
         $codeUrl = 'books/' . $codeId . '/' . $codeId . '.zip';
     }
-    printf('',
-        $resultArray['id'], $resultArray['nid'], $resultArray['title'], $resultArray['category'], $resultArray['datepublished'], $resultArray['numberofpages'], $resultArray['reviewCount'], $resultArray['ratingValue'],
+    printf('',
+        $resultArray['id'], $resultArray['nid'], $resultArray['url'], $resultArray['title'], $resultArray['category_slug'], $resultArray['category'], $resultArray['datepublished'], $resultArray['numberofpages'], $resultArray['reviewCount'], $resultArray['ratingValue'],
         is_file($pdfUrl) ? "pdf" : (strlen($resultArray['pdf']) ? 'nie pobrano' : ''),
         is_file($epubUrl) ? "epub" : (strlen($resultArray['epub']) ? 'nie pobrano' : ''),
         is_file($mobiUrl) ? "mobi" : (strlen($resultArray['mobi']) ? 'nie pobrano' : ''),
idnidTitleCategoryPublish datePagesVotesRating Pdf Epub Mobi Code
%d%d%s%s%s%s%d%.1f %s%s%s%s
%d%d%s%s%s%s%d%.1f %s%s%s%s