Fetch and save info about authors.

This commit is contained in:
krzysiej
2018-06-28 15:01:53 +02:00
parent 91af53fc45
commit b1493f6e70
3 changed files with 55 additions and 5 deletions

View File

@@ -7,15 +7,15 @@ $db = new SQLite3('data.db');
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);
} elseif (isset($_POST['search']) && isset($_POST['title']) && !empty($_POST['title'])) {
} elseif (isset($_GET['search']) && isset($_GET['search_title']) && !empty($_GET['search_title'])) {
$stmt = $db->prepare('SELECT * FROM book WHERE title like :search');
$stmt->bindValue(':search', '%' . $_POST['title'] . '%', SQLITE3_TEXT);
$stmt->bindValue(':search', '%' . $_GET['search_title'] . '%', SQLITE3_TEXT);
} else {
$stmt = $db->prepare('SELECT * FROM book ');
}
$result = $stmt->execute();
echo "<form method='POST'><input type='text' name='title' value='" . ($_POST['title'] ?? '') . "' /><button type='submit' name='search'>Search</button><a href='/'>Clear</a></form>";
echo "<form method='get'><input type='text' name='search_title' value='" . ($_GET['search_title'] ?? '') . "' /><button type='submit' name='search'>Search</button><a href='/'>Clear</a></form>";
echo '<table style="width: 100%">';