From 051b49bb43f0875979ec83cd1cb405c96801f6ed Mon Sep 17 00:00:00 2001 From: Jan-Lukas Pagel Date: Wed, 28 Feb 2018 21:11:28 +0100 Subject: [PATCH] added adding in Admin Panel --- admin/p/ff.php | 23 +++++++++++- admin/scripts/vehicle.php | 77 +++++++++++++++++++++++++++++++++++++++ include/ff.php | 39 ++++++++++---------- 3 files changed, 118 insertions(+), 21 deletions(-) create mode 100644 admin/scripts/vehicle.php diff --git a/admin/p/ff.php b/admin/p/ff.php index 0f82a8d..bceb8f3 100644 --- a/admin/p/ff.php +++ b/admin/p/ff.php @@ -42,6 +42,7 @@ $header->showHeader("Feuerwehr");?>
+

@@ -85,7 +86,7 @@ $header->showHeader("Feuerwehr");?>
- @@ -216,5 +217,25 @@ $header->showHeader("Feuerwehr");?> + + + diff --git a/admin/scripts/vehicle.php b/admin/scripts/vehicle.php new file mode 100644 index 0000000..9d236b0 --- /dev/null +++ b/admin/scripts/vehicle.php @@ -0,0 +1,77 @@ + + + + + + + "; + return; +} + +include '../config/config.inc.php'; +$data = new Config(); + +try { + $pdo = new PDO('mysql:host=' . $data->getSQLHost() . ';dbname=' . $data->getSQLDatabase() . ';charset=utf8mb4', $data->getSQLUser(), $data->getSQLPassword()); +} catch (PDOException $exception) { + echo "Fehler: " . $exception->getMessage(); + exit; +} + +if ($_POST) { + + if (isset($_POST['org'])) { + + if(strcmp($_POST['org'], "ff")) { + if (isset($_POST['ort']) && isset($_POST['name']) && isset($_POST['number']) && isset($_POST['type'])) { + $insert = $pdo->prepare("INSERT INTO feuerwehr (id, OrtID, Organistationskennung, Fahrzeugkennung, Fahrzeugtyp) VALUES (?,?,?,?,?)"); + + $select = $pdo->prepare("SELECT COUNT(OrtID) FROM feuerwehr WHERE OrtID = ?"); + if ($select->execute(array($_POST ['ort']))) { + $count = $select->fetch(); + + if ($count <= 9) { + $count = $_POST['ort'] . "0" . $count; + } else { + $count = $_POST['ort'] . $count; + } + } + $insert->bindParam(1, $count); + $insert->bindParam(2, $_POST['ort']); + $insert->bindParam(3, $_POST['name']); + $insert->bindParam(4, $_POST['number']); + $insert->bindParam(5, $_POST['type']); + $insert->execute(); + echo "Eintrag vom Fahrzeug erfolgreich"; + } + + } + + if(strcmp($_POST['org'], "pol")) { + + } + + if(strcmp($_POST['org'], "rt")) { + + } + + if(strcmp($_POST['org'], "thw")) { + + } + } + +} +?> \ No newline at end of file diff --git a/include/ff.php b/include/ff.php index 2c243cb..ea85b10 100644 --- a/include/ff.php +++ b/include/ff.php @@ -3,7 +3,6 @@ include 'admin/config/config.inc.php'; $data = new Config(); - // Create connection $conn = new mysqli($data->getSQLHost(), $data->getSQLUser(), $data->getSQLPassword(), $data->getSQLDatabase()); mysqli_set_charset($conn, "utf8"); @@ -19,35 +18,36 @@ $result = $conn->query("SELECT * FROM `feuerwehr_pi`"); if ($result->num_rows > 0) { // output data of each row - while($row = $result->fetch_assoc()) { + while ($row = $result->fetch_assoc()) { - if($row['id'] == 10) { + if ($row['id'] == 10) { echo("

Revier Pinneberg

"); } - if($row['id'] == 20) { + if ($row['id'] == 20) { echo("

Revier Elmshorn

"); } - if($row['id'] == 30) { + if ($row['id'] == 30) { echo("

Revier Wedel

"); } - if($row['id'] == 40) { + if ($row['id'] == 40) { echo("

Revier Uetersen

"); } - if($row['id'] == 60) { + if ($row['id'] == 60) { echo("

Revier Hörnerkirchen

"); } - if($row['id'] == 70) { + if ($row['id'] == 70) { echo("

Revier Quickborn

"); } - if($row['id'] == 80) { + if ($row['id'] == 80) { echo("

Revier Barmstedt

"); } -?> + ?>
-
-

]

- + +

]

+
@@ -55,17 +55,15 @@ if ($result->num_rows > 0) { - query("SELECT * FROM `feuerwehr` WHERE OrtID = " . $row['id']); - $fahrzeuge = $conn->query("SELECT * FROM `feuerwehr` WHERE OrtID = ". $row['id'] ); - - if($fahrzeuge->num_rows > 0) { + if ($fahrzeuge->num_rows > 0) { while ($frow = $fahrzeuge->fetch_assoc()) { ?> - + num_rows > 0) { ?>
Fahrzeugtyp
-
+
- \ No newline at end of file + \ No newline at end of file