Ver a proveniência

can now edit multiple title ranks at once

pull/16/head
mauirixxx há 7 anos
ascendente
cometimento
7a51a8def2
2 ficheiros alterados com 41 adições e 10 eliminações
  1. +3
    -8
      includes/titleranks-editor.php
  2. +38
    -2
      includes/titleranks-update.php

+ 3
- 8
includes/titleranks-editor.php Ver ficheiro

@@ -6,21 +6,16 @@ error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
# delete the above when shit finally works

# $tid = $_SESSION['tid'] = titlenameid from database
# $stid = $_POST['editstitle'] = stnameid from database and it should return an array of numbers

echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>stnameid</th><th>titlenameid</th><th>stname</th><th>stpoints</th><th>strank</th></tr>'; //save this line!!!

$ph = implode(",", $_POST['editstitle']);

$sredit = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? AND stnameid IN ($ph)");
$sredit->bind_param("i", $_SESSION['tid']);
$sredit->execute();
$result = $sredit->get_result();
while ($row = $result->fetch_assoc()) {
echo '<tr><td><input type="text" readonly size="4" name="stnameid" value="' . $row['stnameid']. '"></td><td><input type="text" readonly size="4" name="titlenameid" value="' . $row['titlenameid'] . '"></td>';
echo '<td><input type="text" name="stname" value="' . $row['stname'] . '"></td><td><input type="number" min="1" name="stpoints" value="' . $row['stpoints'] . '"></td>';
echo '<td><input type="number" size="4" min="1" max="15" name="strank" value="' . $row['strank'] . '"></td></tr>';
echo '<tr><td><input type="text" readonly size="4" name="stnameid[]" value="' . $row['stnameid']. '"></td><td><input type="text" readonly size="4" name="titlenameid[]" value="' . $row['titlenameid'] . '"></td>';
echo '<td><input type="text" name="stname[]" value="' . $row['stname'] . '"></td><td><input type="number" min="1" name="stpoints[]" value="' . $row['stpoints'] . '"></td>';
echo '<td><input type="number" size="4" min="1" max="15" name="strank[]" value="' . $row['strank'] . '"></td></tr>';
}
echo '</table><br /><input type="hidden" name="title" value="updatesubtitle"><input type="submit" value="Modify title rank(s)"></form>';
echo '<br /><br />';


+ 38
- 2
includes/titleranks-update.php Ver ficheiro

@@ -1,6 +1,42 @@
<?php
echo 'this page will either update the title rank(s) with no human interaction, or<br />';
echo 'delete the specified title rank(s), but require a verification page!<br /><br />';

# delete this block when shit finally works.
ini_set('display_errors', 'on');
error_reporting(E_ALL);
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 '<form action="titlemanager.php" method="post">Please check the box to verify you want to delete: <b>' . $_POST['titlename'] . '</b> <input type="checkbox" name="delsubtitle" value="iamsure">';
echo '<input type="hidden" name="titlenameid" value="' . $_POST['titlenameid'] . '"><input type="hidden" name="title" value="updatesubtitle"><input type="submit" value="Delete title rank(s)"></form><br /><br />';
} 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");
}
} else {
// this section updates the title name
if ($upd = $con->prepare("UPDATE gwsubtitles SET stname = ?, stpoints = ?, strank = ? WHERE titlenameid = ? AND stnameid = ?")) {
$upd->bind_param("siiii", $stname, $stpoints, $strank, $titlenameid, $stnameid);
for ($i = 0; $i < count($_POST['stname']); $i++) {
$stname = $_POST['stname'][$i];
$stpoints = $_POST['stpoints'][$i];
$strank = $_POST['strank'][$i];
$titlenameid = $_POST['titlenameid'][$i];
$stnameid = $_POST['stnameid'][$i];
$upd->execute();
}
$upd->close();
}
echo 'Title rank(s) updated, redirecting!';
header ("Refresh:1; url=titlemanager.php");
}
echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>';
?>

Carregando…
Cancelar
Guardar