Guild Wars stat tracking The idea behind this is to track multiple characters individual stats as well as account stats.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

74 lines
3.3 KiB

  1. <?php
  2. # delete this block when shit finally works.
  3. ini_set('display_errors', 'on');
  4. error_reporting(E_ALL);
  5. mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  6. # delete the above when shit finally works
  7. # use "$_POST['tid']" to show title ranks already associated with the selected title
  8. # and above that list put the input boxes for text and number_format
  9. # investigate if we can put multiple input boxes and loop through them to insert into the database
  10. # https://stackoverflow.com/questions/34469482/how-to-insert-multiple-inputs-into-the-database-using-the-power-of-php
  11. unset($_SESSION['title']);
  12. if (isset($_SESSION['tid'])) {
  13. $_POST['tid'] = $_SESSION['tid'];
  14. }
  15. if (isset($_SESSION['tr'])) {
  16. $tr = $_SESSION['tr'] + 1;
  17. } else {
  18. $trank = $con->prepare("SELECT MAX(strank) FROM gwsubtitles WHERE titlenameid = ?");
  19. $trank->bind_param("i", $_POST['tid']);
  20. $trank->execute();
  21. $trank->store_result();
  22. $trank->bind_result($gwstmr);
  23. while ($trank->fetch()) {
  24. if (is_null($gwstmr)) {
  25. $tr = 1;
  26. } else {
  27. $tr = $gwstmr + 1;
  28. }
  29. }
  30. }
  31. $stmtname = $con->prepare("SELECT titlename, titlemaxrank FROM gwtitles WHERE titlenameid = ?");
  32. $stmtname->bind_param("i", $_POST['tid']);
  33. $stmtname->execute();
  34. $stmtname->store_result();
  35. $stmtname->bind_result($gwtn, $gwtmr);
  36. while ($stmtname->fetch()) {
  37. echo 'Adding rank to title <b>' . $gwtn . '</b><br />The maximum rank achievable in game is ' . $gwtmr . '<br />';
  38. if ($tr > $gwtmr) {
  39. echo '<br />No more ranks can be added!<br /><br />';
  40. } else {
  41. echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>Title Rank Name</th><th>Title Points</th><th>Rank Level</th></tr>';
  42. echo '<tr><td><input type="text" name="titlerankname" required autofocus></td><td><input type="number" name="titlepoints" required></td><td><input type="number" readonly name="titlerank" min="1" max="15" value="' . $tr . '"></tr>';
  43. echo '</table><br /><input type="hidden" name="title" value="titleranksubmit"><input type="hidden" name="titlenameid" value="' . $_POST['tid'] . '"><input type="submit" value="Add title rank ..."></form>';
  44. }
  45. }
  46. $stmtname->free_result();
  47. $stmtname->close();
  48. echo 'Here are the currently associated title ranks, starting with rank 1:<br />';
  49. 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><th>Edit</th></tr>';
  50. $stmtview = $con->prepare("SELECT * FROM gwsubtitles WHERE titlenameid = ? ORDER BY strank ASC");
  51. $stmtview->bind_param("i", $_POST['tid']);
  52. $stmtview->execute();
  53. $result = $stmtview->get_result();
  54. while ($row = $result->fetch_assoc()) {
  55. $stnid = $row['stnameid'];
  56. $tnid = $row['titlenameid'];
  57. $stname = $row['stname'];
  58. $stpoints = $row['stpoints'];
  59. $strank = $row['strank'];
  60. echo '<tr><td>' . $stnid . '<td>' . $tnid . '</td><td>' . $stname . '</td><td>' . number_format($stpoints) . '</td><td>' . $strank . '</td><td><input type="checkbox" name="editstitle[]" value="' . $stnid . '"></td></tr>';
  61. }
  62. $stmtview->close();
  63. $_SESSION['tid'] = $_POST['tid'];
  64. echo '</table><br /><input type="hidden" name="title" value="modsubtitle"><input type="submit" value="Edit selected titles"></form><br />If anything looks off, please fix it!<br /><br />';
  65. echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>';
  66. ?>