From f402e0c96a52c73ab390b76f637af3ccde6ac8b2 Mon Sep 17 00:00:00 2001 From: UMTS at Teleco Date: Fri, 14 Feb 2025 03:12:25 +0100 Subject: initial upload ... somewhat cleaned up and "less" swearing included --- admin/tools/edit_row.php | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 admin/tools/edit_row.php (limited to 'admin/tools/edit_row.php') diff --git a/admin/tools/edit_row.php b/admin/tools/edit_row.php new file mode 100644 index 0000000..ceb59f3 --- /dev/null +++ b/admin/tools/edit_row.php @@ -0,0 +1,80 @@ +query("PRAGMA table_info($table)"); +while ($row = $columnsResult->fetchArray(SQLITE3_ASSOC)) { + $columns[] = $row['name']; +} + +$stmt = $db->prepare("SELECT * FROM $table WHERE id = :id"); +$stmt->bindValue(':id', $id, SQLITE3_INTEGER); +$result = $stmt->execute(); + +if ($result) { + $row = $result->fetchArray(SQLITE3_ASSOC); +} else { + $row = null; +} + +if (isset($_POST['save_changes'])) { + foreach ($columns as $column) { + $value = $_POST[$column] ?: null; + if ($column == 'date' && empty($value)) { + $value = date('Y-m-d H:i:s'); + } + if ($table == 'content' && $column == 'custom_html') { + $value = $value ? 1 : 0; + } + $stmt = $db->prepare("UPDATE $table SET $column = :value WHERE id = :id"); + $stmt->bindValue(':value', $value, SQLITE3_TEXT); + $stmt->bindValue(':id', $id, SQLITE3_INTEGER); + $stmt->execute(); + } + header("Location: edit_database.php?table=$table"); + exit(); +} +?> + + + + + + Edit Row + + +

Edit Row in Table:

+
+ + + + + + + +
+ + +
+ Back to Table + + -- cgit v1.2.3-70-g09d2