]> gitweb.morketsmerke.org Git - sc.git/commitdiff
Dodanie możliwości przeniesienia stron między kategoriami - BT #186. main
authorxf0r3m <jakubstasinski@protonmail.com>
Tue, 23 Jul 2024 07:00:10 +0000 (09:00 +0200)
committerxf0r3m <jakubstasinski@protonmail.com>
Tue, 23 Jul 2024 07:00:10 +0000 (09:00 +0200)
index.php
style.css

index 2f68564f472baac6ff66648aaa562af24fdce266..0d09b7356f3dd7e78b338716159e6aac9f27346f 100644 (file)
--- a/index.php
+++ b/index.php
           </div>
           <ul class="list-group list-group-flush">
             <?php
+              #Przeniesienie strony do innej kategorii
+              if ( isset($_POST['newCateId']) ) {
+                $tableName = "sites";
+                $setValue = "cateId = " . mysqli_real_escape_string($connection, $_POST['newCateId']);
+                $whereValue = "id = " . mysqli_real_escape_string($connection, $_POST['movedSiteId']);
+                $result = dbUpdate($connection, $tableName, $setValue, $whereValue); 
+              }
               #Usunięcie strony
               if ( isset($_POST['siteId']) ) {
                 $tableName = "sites";
                   <input type=\"hidden\" name=\"siteId\" value=\"" . $row[0] . "\">
                   <button type=\"submit\" class=\"btn btn-danger deleteButton\" title=\"Usuń\">&times;</button>
                   </form>
-                  <a href=\"" . $row[2] . "\">". $row[1] . "</a></li>";
+                  <a href=\"" . $row[2] . "\">". $row[1] . "</a>";
+                  echo "<form class=\"moveForm\" action=\"" . $_SERVER['REQUEST_URI'] . "\" method=\"post\">";
+                  echo "<input type=\"hidden\" name=\"movedSiteId\" value=\"" . $row[0] . "\">";
+                  echo "<select class=\"form-select moveSelect\" name=\"newCateId\">";
+                  echo "<option></option>";
+                    $tableName = 'categories';
+                    $columnScheme = "id,name";
+                    $whereValue = "1=1";
+                    $result2 = dbQuery($connection, $tableName, $columnScheme, $whereValue);
+                    if ( ! is_null($result2) ) {
+                      while ( $row2 = mysqli_fetch_row($result2) ) {
+                        echo "<option value=\"" . $row2[0] . "\">" . $row2[1] . "</option>";
+                      }
+                    }
+                  echo "</select>";
+                  echo "<button type=\"submit\" class=\"btn btn-warning moveButton\">Przenieś</button>";
+                  echo "</form>";
+                  echo "</li>";
                   } else {
                     echo "<li class=\"list-group-item\">
                     <a href=\"" . $row[2] . "\">" . $row[1] . "</a></li>";
index daa7f3f9f1562b346016d3f567079495bb8a7c4e..d6313d822616eb9c2717bd44d9f9ba430639cafd 100644 (file)
--- a/style.css
+++ b/style.css
 .delForms {
   display: inline;
 }
+
+.moveSelect {
+  display: inline;
+  width: 37%;
+  margin-right: 20px;
+}
+
+.moveButton {
+  margin-bottom: 5px;
+}
+
+.moveForm {
+  margin-top: 16px;
+}