delete entries in statistic
This commit is contained in:
21
app/public/delete_statistics.php
Normal file
21
app/public/delete_statistics.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include("../scripts/connection.php");
|
||||||
|
include("../scripts/functions.php");
|
||||||
|
$user_data = check_login($con);
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||||
|
try {
|
||||||
|
$stmt = $con->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;
|
||||||
|
?>
|
||||||
@@ -16,6 +16,7 @@ function init() {
|
|||||||
team_edit_button();
|
team_edit_button();
|
||||||
team_delete_button();
|
team_delete_button();
|
||||||
station_delete_button();
|
station_delete_button();
|
||||||
|
statistic_delete_button();
|
||||||
}
|
}
|
||||||
|
|
||||||
var selected = null;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if ($session != "total-score") {
|
if ($session != "total-score") {
|
||||||
|
//add edit button
|
||||||
echo "<div>
|
echo "<div>
|
||||||
<form action=\"edit_statistics.php\" method=\"get\">
|
<form action=\"edit_statistics.php\" method=\"get\">
|
||||||
<input type=\"button\" id=\"edit_statistic\" value=\"Eintrag bearbeiten\" class=\"edit\" disabled=true/>
|
<input type=\"button\" id=\"edit_statistic\" value=\"Eintrag bearbeiten\" class=\"edit\" disabled=true/>
|
||||||
@@ -55,6 +56,14 @@
|
|||||||
<input type=\"hidden\" id=\"station_id\" name=\"s_id\" value=\"". $session . "\"/>
|
<input type=\"hidden\" id=\"station_id\" name=\"s_id\" value=\"". $session . "\"/>
|
||||||
</form>
|
</form>
|
||||||
</div>";
|
</div>";
|
||||||
|
//add delete button
|
||||||
|
echo "<div>
|
||||||
|
<form action=\"delete_statistics.php\" method=\"post\">
|
||||||
|
<input type=\"button\" id=\"delete_statistic\" value=\"Löschen\" class=\"edit\" disabled=\"true\"/>
|
||||||
|
<input type=\"hidden\" id=\"m_id_delete\" name=\"m_id\"/>
|
||||||
|
<input type=\"hidden\" id=\"s_id_delete\" name=\"s_id\" value=\"" . $session . "\"/>
|
||||||
|
</form>
|
||||||
|
</div>";
|
||||||
} ?>
|
} ?>
|
||||||
<div class="table-div">
|
<div class="table-div">
|
||||||
<table id="table">
|
<table id="table">
|
||||||
|
|||||||
Reference in New Issue
Block a user