diff --git a/app/public/delete_statistics.php b/app/public/delete_statistics.php new file mode 100644 index 0000000..0fb7a7c --- /dev/null +++ b/app/public/delete_statistics.php @@ -0,0 +1,21 @@ +prepare("DELETE FROM Punkte WHERE m_id = ? AND s_id = ?"); + $stmt->bindParam(1, $_POST["m_id"], PDO::PARAM_INT); + $stmt->bindParam(2, $_POST["s_id"], PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + handle_pdo_exception($e); + } + } + + $con = null; + header("Location: statistik.php"); + die; +?> \ No newline at end of file diff --git a/app/public/js/edit_table.js b/app/public/js/edit_table.js index fabe8c8..a86f940 100644 --- a/app/public/js/edit_table.js +++ b/app/public/js/edit_table.js @@ -16,6 +16,7 @@ function init() { team_edit_button(); team_delete_button(); station_delete_button(); + statistic_delete_button(); } var selected = null; @@ -124,4 +125,18 @@ function station_delete_button() { } } } +} + +function statistic_delete_button() { + var button = document.getElementById('delete_statistic'); + if(button != null) { + button.onclick = function() { + var row = document.getElementsByClassName('row selected')[0]; + document.getElementById('m_id_delete').value = row.id; + let confirmAction = confirm("Wirklich löschen?"); + if (confirmAction) { + this.form.submit(); + } + } + } } \ No newline at end of file diff --git a/app/public/statistik.php b/app/public/statistik.php index 289d776..f212457 100644 --- a/app/public/statistik.php +++ b/app/public/statistik.php @@ -48,6 +48,7 @@
"; + //add delete button + echo "