Przeglądaj źródła

added percentage complete bars, and now calculates the overall percentage completed of a title

pull/16/head
mauirixxx 7 lat temu
rodzic
commit
8db262f4df
3 zmienionych plików z 26 dodań i 9 usunięć
  1. +11
    -4
      includes/getaccountstats.php
  2. +12
    -4
      includes/update-titleranks.php
  3. +3
    -1
      style.css

+ 11
- 4
includes/getaccountstats.php Wyświetl plik

@@ -4,9 +4,9 @@
// remove the above 2 lines
if (isset($_SESSION['userid'])) {
echo '<table border="1"><caption>Account wide stats</caption>';
echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Next Rank</th></tr>';
echo '<tr><th>Title</th><th>Title Rank</th><th>Title Points</th><th>Current Rank</th><th>Points Remaining</th><th>Max Title %</th><th>Next Rank</th></tr>';
// $gas = GetAccountStats
$gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ?");
$gas = $con->prepare("SELECT * FROM gwaccstats WHERE userid = ? AND accid = ? ORDER BY currentstrank DESC, percent ASC");
$gas->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']);
$gas->execute();
$result = $gas->get_result();
@@ -34,8 +34,15 @@ if (isset($_SESSION['userid'])) {
$row['currentstrankname'] = "No title earned yet!";
$row['currentstrank'] = "0";
}
echo '<tr><td>' . $titlename . '</td><td>' . $row['currentstrankname'] . '</td><td>' . number_format($row['titlepoints']) . '</td><td>' . $row['currentstrank'] . '</td>';
echo '<td>' . $pr . '</td><td>' . $stname . '</td></tr>';
if ($row['percent'] > 100) {
$ohp = 100;
} else {
$ohp = $row['percent'];
}
echo '<tr><td style="width:150px;">' . $titlename . '</td><td style="width:200px;">' . $row['currentstrankname'] . '</td><td style="width:100px;">' . number_format($row['titlepoints']) . '</td><td style="width:70px;">' . $row['currentstrank'] . '</td>';
echo '<td style="width:100px;">' . $pr . '</td><td><div class="percentbar" style="width:100px;"><div style="width:' . $ohp . 'px;"></div></div>';
echo $ohp;
echo '% completed</td><td>' . $stname . '</td></tr>';
}
$gas->close();
echo '</table><br />';


+ 12
- 4
includes/update-titleranks.php Wyświetl plik

@@ -15,17 +15,25 @@ if (isset($_SESSION['userid'])) {
$gcr->bind_result($stnameid, $stname, $strank);
$gcr->fetch();
$gcr->close();
// $gpc = Get Percentage Completed
$gpc = $con->prepare("SELECT stpoints FROM gwsubtitles WHERE titlenameid = ? ORDER BY stnameid DESC LIMIT 1");
$gpc->bind_param("i", $_POST['titlenameid']);
$gpc->execute();
$gpc->bind_result($pmr); //$pmr = Percentage Max Rank
$gpc->fetch();
$gpc->close();
$progress = ceil(($_POST['titlepoints'] / $pmr) * 100);
if ($r1 > 0) {
// $urs = Update Rank Stats
$urs = $con->prepare("UPDATE gwaccstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ? WHERE titlenameid = ? AND accid = ? AND userid = ?");
$urs->bind_param("iisiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']);
$urs = $con->prepare("UPDATE gwaccstats SET stnameid = ?, titlepoints = ?, currentstrankname = ?, currentstrank = ?, percent = ? WHERE titlenameid = ? AND accid = ? AND userid = ?");
$urs->bind_param("iisiiiii", $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_POST['titlenameid'], $_SESSION['prefaccid'], $_SESSION['userid']);
$urs->execute();
$urs->close();
echo 'Title has been updated!<br /><br />';
} else {
// $irs = Insert Rank Stats
$irs = $con->prepare("INSERT INTO gwaccstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?)");
$irs->bind_param("iiisiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $_SESSION['prefaccid'], $_SESSION['userid']);
$irs = $con->prepare("INSERT INTO gwaccstats (titlenameid, stnameid, titlepoints, currentstrankname, currentstrank, percent, accid, userid) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$irs->bind_param("iiisiiii", $_POST['titlenameid'], $stnameid, $_POST['titlepoints'], $stname, $strank, $progress, $_SESSION['prefaccid'], $_SESSION['userid']);
$irs->execute();
$irs->close();
echo 'Title entered!<br /></br />';


+ 3
- 1
style.css Wyświetl plik

@@ -66,4 +66,6 @@ input {
submitLink:focus {
outline: none;
}
}

.percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; }
.percentbar div { background: #28B8C0; height: 10px; }

Ładowanie…
Anuluj
Zapisz