<!-- PHP CODE -->
<?php
+ if ( isset($_POST['addbook-type']) ) {
+ $tableName = 'books';
+ $columnScheme = "type,coverlink,title,author,publisher,publishing,pubdate,category,ISBN,adnotes,description";
+ $setValues = intval($_POST['addbook-type']) . ",'"
+ . mysqli_real_escape_string($connection, $_POST['addbook-coverlink']) . "','"
+ . mysqli_real_escape_string($connection, $_POST['addbook-title']) . "','"
+ . mysqli_real_escape_string($connection, $_POST['addbook-author']) . "','"
+ . mysqli_real_escape_string($connection, $_POST['addbook-publisher']) . "',"
+ . intval($_POST['addbook-publishing']) . "," . intval($_POST['addbook-pubdate']) . ","
+ . intval($_POST['addbook-category']) . ",'" . mysqli_real_escape_string($connection, $_POST['addbook-isbn']) . "','"
+ . mysqli_real_escape_string($connection, $_POST['addbook-adnotes']) . "','"
+ . mysqli_real_escape_string($connection, $_POST['addbook-desc']) . "'";
+
+ $addBookResult = dbAdd($connection, $tableName, $columnScheme, $setValues);
+ if ( mysqliResult($connection, $addBookResult) ) {
+ echo "<h3>Książka \"" . $_POST['addbook-title'] . "\" została dodana.</h3>";
+ } else {
+ echo "<h3 style=\"color: red;\">Książka nie została dodana</h3>";
+ }
+ }
?>
<!-- HTML FORM -->
-
+<form action="?p=addbook" method="post">
+ <label for="book-type">Typ książki:</label><br />
+ <div id="book-type">
+ Książka papierowa <input type="radio" name="addbook-type" value="0" />
+
+ E-Book <input type="radio" name="addbook-type" value="1" />
+ </div><br />
+ <label for="book-cover-link">Adres do okładki:</label><br />
+ <input class="addbook-input" id="book-cover-link" type="text" name="addbook-coverlink" /><br />
+ <label for="book-title">Tytuł:</label><br />
+ <input class="addbook-input" id="book-title" type="text" name="addbook-title" /><br />
+ <label for="book-author">Autor:</label><br />
+ <input class="addbook-input" id="book-author" type="text" name="addbook-author" /><br />
+ <label for="book-publisher">Wydawnictwo:</label><br />
+ <input class="addbook-input" id="book-publisher" type="text" name="addbook-publisher" /><br />
+ <label for="book-publishing">Wydanie:</label><br />
+ <input class="addbook-input" id="book-publishing" type="number" name="addbook-publishing" /><br />
+ <label for="book-pubdate">Rok wydania:</label><br />
+ <input class="addbook-input" id="book-pubdate" type="number" name="addbook-pubdate" /><br />
+ <label for="book-categorie">Kategoria:</label><br />
+ <select class="addbook-input" id="book-categorie" name="addbook-category" />
+ <option></option>
+ <?php
+ $tableName = 'categories';
+ $columnScheme = 'id,name';
+ $whereValue = '1=1';
+ $addbookCategoryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+ if ( mysqli_num_rows($addbookCategoryResult) > 0 ) {
+ while ( $row = mysqli_fetch_row($addbookCategoryResult) ) {
+ echo "<option value=\"" . $row[0] . "\">" . $row[1] . "</option>";
+ }
+ }
+ ?>
+ </select><br />
+ <label for="book-isbn">Numer ISBN:</label><br />
+ <input class="addbook-input" id="book-isbn" type="text" name="addbook-isbn" /><br />
+ <label for="book-adnotes">Adnotacje (informacje dodatkowe):</label><br />
+ <textarea id="boot-adnotes" name="addbook-adnotes" rows="15" cols="50"></textarea><br />
+ <label for="book-desc">Opis</label><br />
+ <textarea id="book-desc" name="addbook-desc" rows="15" cols="50"></textarea><br /><br />
+ <button type="submit">Dodaj książkę</button>
+</form>
<input type="text" name="categorie" /><br /><br />
<button type="submit">Dodaj kategorię</button>
</form>
+<hr />
+<h3>Kategorie:</h3>
+<?php
+ $tableName = "categories";
+ $columnScheme = "id,name";
+ $whereValue = "1=1";
+ $printCategoriesResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+ if ( mysqliResult($connection, $printCategoriesResult) ) {
+ echo "<table>";
+ echo "<tr><th>Kategoria</th><th>Usuń</th></tr>";
+ while ( $row = mysqli_fetch_row($printCategoriesResult) ) {
+ echo "<tr><td><a href=\"?p=books&sortby=category&id=" . $row[0] . "\">" . $row[1] . "</a></td>";
+ echo "<td style=\"text-align: center;\"><a href=\"?p=delete&table=categories&id=" . $row[0] . "\" style=\"text-decoration: none\"><button><span style=\"color: red; font-size: 16px;\">✖</span></button></a></td></tr>";
+ }
+ echo "</table>";
+ } else {
+ echo "<h3>Nieznaleziono żadnych kategorii.</h3>";
+ }
+?>
--- /dev/null
+<!-- PHP CODE -->
+<?php
+ if ( session_status() != 2 ) { session_start(); }
+ $tableName = "books";
+ $columnScheme = "id,title,author";
+ $whereValue = "type = " . intval($_GET['t']);
+ $booksQueryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue)
+?>
+<!-- HTML FORM -->
+<?php
+ if ( isset($_GET['t']) && ( $_GET['t'] == 1 ) ) {
+ echo "<h3>E-Booki:</h3><br />";
+ } else {
+ echo "<h3>Książki papierowe:</h3><br />";
+ }
+ if ( mysqliResult($connection, $booksQueryResult) ) {
+ echo "<table>";
+ echo "<tr><th>Książka</th>";
+ if ( isset($_SESSION['username']) ) {
+ echo "<th>Edytuj</th><th>Usuń</th>";
+ }
+ echo "</tr>";
+ while ( $row = mysqli_fetch_row($booksQueryResult) ) {
+ echo "<tr>";
+ echo "<td style=\"background-color: #17a2b8;\"><a href=\"?p=book&id=" . $row[0] . "\">" . $row[1] . "</a><br />";
+ echo "<a href=\"?p=books&a=" . urlencode($row[2]) . "\" style=\"color: gray;\">";
+ echo "<small style=\"color: gray;\"><em>" . $row[2] . "</em></small></a></td>";
+ if ( isset($_SESSION['username']) ) {
+ echo "<td style=\"text-align: center;background-color: #17a2b8;\"><a href=\"?p=editbook&id=" . $row[0] . "\" style=\"text-decoration: none;\">";
+ echo "<button><span style=\"color: #ffc107; font-size: 16px;\">✎</span></button></a></td>";
+ echo "<td style=\"text-align: center;background-color: #17a2b8;\"><a href=\"?p=delete&table=books&id=" . $row[0] . "\" style=\"text-decoration: none;\">";
+ echo "<button><span style=\"color: red; font-size: 16px;\">✖</span></button></a></td>";
+ }
+ echo "</tr>";
+ }
+ echo "</table>";
+ }
+?>