| @@ -4,9 +4,9 @@ | |||||
| // remove the above 2 lines | // remove the above 2 lines | ||||
| if (isset($_SESSION['userid'])) { | if (isset($_SESSION['userid'])) { | ||||
| echo '<table border="1"><caption>Account wide stats</caption>'; | 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 = 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->bind_param("ii", $_SESSION['userid'], $_SESSION['prefaccid']); | ||||
| $gas->execute(); | $gas->execute(); | ||||
| $result = $gas->get_result(); | $result = $gas->get_result(); | ||||
| @@ -34,8 +34,15 @@ if (isset($_SESSION['userid'])) { | |||||
| $row['currentstrankname'] = "No title earned yet!"; | $row['currentstrankname'] = "No title earned yet!"; | ||||
| $row['currentstrank'] = "0"; | $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(); | $gas->close(); | ||||
| echo '</table><br />'; | echo '</table><br />'; | ||||
| @@ -15,17 +15,25 @@ if (isset($_SESSION['userid'])) { | |||||
| $gcr->bind_result($stnameid, $stname, $strank); | $gcr->bind_result($stnameid, $stname, $strank); | ||||
| $gcr->fetch(); | $gcr->fetch(); | ||||
| $gcr->close(); | $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) { | if ($r1 > 0) { | ||||
| // $urs = Update Rank Stats | // $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->execute(); | ||||
| $urs->close(); | $urs->close(); | ||||
| echo 'Title has been updated!<br /><br />'; | echo 'Title has been updated!<br /><br />'; | ||||
| } else { | } else { | ||||
| // $irs = Insert Rank Stats | // $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->execute(); | ||||
| $irs->close(); | $irs->close(); | ||||
| echo 'Title entered!<br /></br />'; | echo 'Title entered!<br /></br />'; | ||||
| @@ -66,4 +66,6 @@ input { | |||||
| submitLink:focus { | submitLink:focus { | ||||
| outline: none; | outline: none; | ||||
| } | } | ||||
| } | |||||
| .percentbar { background:#CCCCCC; border:1px solid #666666; height:10px; } | |||||
| .percentbar div { background: #28B8C0; height: 10px; } | |||||