From 69db1aa93c53e04ad00762e85a831fa5047904c1 Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Tue, 7 Aug 2018 16:10:16 -1000 Subject: [PATCH] can now delete selected title ranks --- includes/titleranks-editor.php | 4 ++-- includes/titleranks-update.php | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/includes/titleranks-editor.php b/includes/titleranks-editor.php index 469c6bd..c1ba101 100644 --- a/includes/titleranks-editor.php +++ b/includes/titleranks-editor.php @@ -6,7 +6,7 @@ error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works -echo '
'; //save this line!!! +echo '
stnameidtitlenameidstnamestpointsstrank
'; $ph = implode(",", $_POST['editstitle']); $sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)"); $sredit->bind_param("i", $_SESSION['tid']); @@ -15,7 +15,7 @@ $result = $sredit->get_result(); while ($row = $result->fetch_assoc()) { echo ''; echo ''; - echo ''; + echo ''; } echo '
stnameidtitlenameidstnamestpointsstrankDelete?

'; echo '

'; diff --git a/includes/titleranks-update.php b/includes/titleranks-update.php index 5dd6d7a..5871e93 100644 --- a/includes/titleranks-update.php +++ b/includes/titleranks-update.php @@ -7,20 +7,22 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); # delete the above when shit finally works if (isset($_POST['delsubtitle'])) { - if ($_POST['delsubtitle'] =="yes") { - // this title makes you verify that you want to delete this title - echo '
Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; - echo '


'; - } else if ($_POST['delsubtitle'] == "iamsure") { - // this section actually deletes the title rank(s) - # need to deal with array data eventually - $stmtdel = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ?"); - $stmtdel->bind_param("i", $_POST['titlenameid']); - $stmtdel->execute(); - $stmtdel->close(); - echo 'Title rank(s) have been deleted, redirecting!'; - header ("Refresh:1; url=titlemanager.php"); + echo 'the post delsubtitle might be an array??
'; + echo '
';
+	print_r($_POST['delsubtitle']);
+	print_r($_POST['stnameid']);
+	echo '
'; + if ($delst = $con->prepare("DELETE FROM gwsubtitles WHERE titlenameid = ? AND stnameid = ?")) { + $delst->bind_param("ii", $tnameid, $stnameid); + for ($i = 0; $i < count($_POST['delsubtitle']); $i++) { + $tnameid = $_POST['titlenameid'][$i]; + $stnameid = $_POST['delsubtitle'][$i]; + $delst->execute(); + } + $delst->close(); } + echo 'Title rank(s) have been deleted, redirecting!'; + //header ("Refresh:1; url=titlemanager.php"); } else { // this section updates the title name if ($upd = $con->prepare("UPDATE gwsubtitles SET stname = ?, stpoints = ?, strank = ? WHERE titlenameid = ? AND stnameid = ?")) {