diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php
index ce5241a..af438a7 100644
--- a/includes/getaccountstats.php
+++ b/includes/getaccountstats.php
@@ -4,9 +4,9 @@
// remove the above 2 lines
if (isset($_SESSION['userid'])) {
echo '
Account wide stats';
- echo '| Title | Title Rank | Title Points | Current Rank | Points Remaining | Next Rank |
';
+ echo '| Title | Title Rank | Title Points | Current Rank | Points Remaining | Max Title % | Next Rank |
';
// $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 '| ' . $titlename . ' | ' . $row['currentstrankname'] . ' | ' . number_format($row['titlepoints']) . ' | ' . $row['currentstrank'] . ' | ';
- echo '' . $pr . ' | ' . $stname . ' |
';
+ if ($row['percent'] > 100) {
+ $ohp = 100;
+ } else {
+ $ohp = $row['percent'];
+ }
+ echo '| ' . $titlename . ' | ' . $row['currentstrankname'] . ' | ' . number_format($row['titlepoints']) . ' | ' . $row['currentstrank'] . ' | ';
+ echo '' . $pr . ' | ';
+ echo $ohp;
+ echo '% completed | ' . $stname . ' |
';
}
$gas->close();
echo '
';
diff --git a/includes/update-titleranks.php b/includes/update-titleranks.php
index eab365a..a729efd 100644
--- a/includes/update-titleranks.php
+++ b/includes/update-titleranks.php
@@ -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!
';
} 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!
';
diff --git a/style.css b/style.css
index d6811ec..e6babb0 100644
--- a/style.css
+++ b/style.css
@@ -66,4 +66,6 @@ input {
submitLink:focus {
outline: none;
}
-}
\ No newline at end of file
+
+.percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; }
+.percentbar div { background: #28B8C0; height: 10px; }
\ No newline at end of file