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';
    $mobiUrl = 'books/' . $resultArray['nid'] . '/' . $resultArray['nid'] . '.mobi';
    $codeUrl = '';
    if (preg_match('#\d+#', $resultArray['code'], $found)) {
        $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'],
        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' : ''),
        is_file($codeUrl) ? "zip" : (strlen($resultArray['code']) ? 'nie pobrano' : '')
    );
    if ($resultArray) {
        $x = $resultArray;
    }
}
echo '
idnidTitleCategoryPublish datePagesVotesRating Pdf Epub Mobi Code
%d%d%s%s%s%s%d%.1f %s%s%s%s
';