+<!-- PHP CODE -->
+<?php
+ if ( isset($_POST['editmag-id']) ) {
+ $tableName = 'magazines';
+ #$columnScheme = "type,coverlink,title,author,publisher,publishing,pubdate,category,ISBN,adnotes,description";
+ $setValues = "cover = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-cover']) . "', title = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-title']) . "', pubnumber = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-pubnumber']) . "', source = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-source']) . "', category = "
+ . intval($_POST['editmag-category']) . ", adnotes = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-adnotes']) . "', description = '"
+ . mysqli_real_escape_string($connection, $_POST['editmag-desc']) . "'";
+ $whereValue = 'id = ' . intval($_POST['editmag-id']);
+ $editMagResult = dbUpdate($connection, $tableName, $setValues, $whereValue);
+ if ( mysqliResult($connection, $editMagResult) ) {
+ echo "<h3>Zamiany zostały zapisane.</h3>";
+ } else {
+ echo "<h3 style=\"color: red;\">Zmiany nie zostały zapisne.</h3>";
+ }
+ }
+ $tableName = 'magazines';
+ $columnScheme = '*';
+ if ( ! isset($_GET['id'] ) ) {
+ $whereValue = 'id = ' . intval($_POST['editmag-id']);
+ } else {
+ $whereValue = 'id = ' . intval($_GET['id']);
+ }
+ $editMagResult = dbQuery($connection, $tableName, $columnScheme, $whereValue)
+?>
+<!-- HTML FORM -->
+<?php
+ if ( mysqliResult($connection, $editMagResult) ) {
+ $row = mysqli_fetch_row($editMagResult);
+?>
+ <form action="?p=editmagazine" method="post">
+ <input type="hidden" name="editmag-id" value="<?php echo $row[0]; ?>" />
+ <label for="mag-cover">Adres do okładki:</label><br />
+ <input class="addbook-input" id="mag-cover" type="text" name="editmag-cover" value="<?php echo $row[1]; ?>" /><br />
+ <label for="mag-title">Tytuł:</label><br />
+ <input class="addbook-input" id="mag-title" type="text" name="editmag-title" value="<?php echo $row[2]; ?>" /><br />
+ <label for="mag-pubnumber">Numer:</label><br />
+ <input class="addbook-input" id="mag-pubnumber" type="text" name="editmag-pubnumber" value="<?php echo $row[3]; ?>" /><br />
+ <label for="mag-source">Link:</label><br />
+ <input class="addbook-input" id="mag-source" type="text" name="editmag-source" value="<?php echo $row[4]; ?>" /><br />
+ <label for="mag-category">Kategoria:</label><br />
+ <select class="addbook-input" id="mag-category" name="editmag-category" />
+ <?php
+ $tableName = 'categories';
+ $columnScheme = 'id,name';
+ $whereValue = '1=1';
+ $editMagCategoryResult = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+ if ( mysqli_num_rows($editMagCategoryResult) > 0 ) {
+ while ( $row2 = mysqli_fetch_row($editMagCategoryResult) ) {
+ if ( $row2[0] == $row[5] ) {
+ echo "<option value=\"" . $row[5] . "\" selected>" . $row2[1] . "</option>";
+ } else {
+ echo "<option value=\"" . $row2[0] . "\">" . $row2[1] . "</option>";
+ }
+ }
+ }
+ ?>
+ </select><br />
+ <label for="mag-adnotes">Adnotacje (informacje dodatkowe):</label><br />
+ <textarea id="mag-adnotes" name="editmag-adnotes" rows="15" cols="50"><?php echo $row[6]; ?></textarea><br />
+ <label for="mag-desc">Opis:</label><br />
+ <textarea id="mag-desc" name="editmag-desc" rows="15" cols="50"><?php echo $row[7]; ?></textarea><br /><br />
+ <button type="submit">Zapisz zmiany</button>
+</form>
+<?php
+ } else {
+ echo "<h3>Nie odnaleziono takiego czasopisma.</h3>";
+ }
+?>