Hallo, bin gerade dabei eine Ranking Liste zu programmieren und bin nun auf ein problem gestoßen wenn man auf der Rank liste z.b. auf seite 2 wechselt fängt er wieder an ab Rank 1 zu zählen, wie bekomme ich es hin das er die ränge einfach weiter zählt.
Hier meine Ranglisten code:
Ranking.php
Code:
<?php
require_once("../test/perpage.php");
require_once("../test/dbcontroller.php");
$db_handle = new DBController();
$user = "";
$code = "";
$queryCondition = "";
if(!empty($_POST["search"])) {
foreach($_POST["search"] as $k=>$v){
if(!empty($v)) {
$queryCases = array("username");
if(in_array($k,$queryCases)) {
if(!empty($queryCondition)) {
$queryCondition .= "username";
} else {
$queryCondition .= "username";
}
}
}
}
}
$sql = "SELECT username, total_play_one_minute FROM MineTrax.players ORDER BY total_play_one_minute DESC" . $queryCondition;
$href = 'ranking/balancetop25.php';
$rank = 1;
$perPage = 2;
$page = 1;
if(isset($_POST['page'])){
$page = $_POST['page'];
}
$start = ($page-1)*$perPage;
if($start < 0) $start = 0;
$query = $sql . $orderby . " limit " . $start . "," . $perPage;
$result = $db_handle->runQuery($query);
if(!empty($result)) {
$result["perpage"] = showperpage($sql, $perPage, $href);
}
?>
<html>
<head>
<title>Rangliste</title>
<link href="../css/ranking.css" type="text/css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script src="../js/main.js" type="text/javascript"></script>
<?php require "../config.php";?>
<?php require "../menu.php";?>
</head>
<body>
<div id="toys-grid">
<form name="frmSearch" method="post" action="balancetop25.php">
<div class="search-box">
<p><input type="text" placeholder="Name" name="search[username]" class="demoInputBox" value="<?php echo $user ?>" /> <input type="submit" name="go" class="btnSearch" value="Search"> <input type="reset" class="btnSearch" value="Reset" onclick="window.location='index.php'"></p>
</div>
<table cellpadding="10" cellspacing="1">
<thead>
<tr>
<th><strong>#</strong></th>
<th><strong>Spieler</strong></th>
<th><strong>Price</strong></th>
<th><strong>Stock Count</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php
if(!empty($result)) {
foreach($result as $k=>$v) {
if(is_numeric($k)) {
?>
<tr>
<td><?php echo $rank; ?></td>
<td><?php echo "<img src="https://cravatar.eu/avatar/{$result[$k][username]}"/> {$result[$k]['username']} "?></td>
<td><?php echo $result[$k]["categorie"]; ?></td>
<td><?php echo date('Y-m-d H:i:s', date ($result[$k]["total_play_one_minute"])); ?></td>
<td><?php echo $result[$k]["stock_count"]; ?></td>
<td>
<a class="btnEditAction" href="edit.php?id=<?php echo $result[$k]["id"]; ?>">Edit</a> <a class="btnDeleteAction" href="delete.php?action=delete&id=<?php echo $result[$k]["id"]; ?>">Delete</a>
</td>
</tr>
<?php
$rank++;
}
}
}
if(isset($result["perpage"])) {
?>
<tr>
<td colspan="6" align=right> <?php echo $result["perpage"]; ?></td>
</tr>
<?php } ?>
<tbody>
</table>
</form>
</div>
<?php require "../footer.php";?>
</body>
</html>
Perpage.php:
Code:
<?php
function perpage($rank, $per_page = '10',$href) {
$output = '';
$paging_id = "link_perpage_box";
if(!isset($_POST["page"])) $_POST["page"] = 1;
if($per_page != 0)
$pages = ceil($rank/$per_page);
if($pages>1) {
if(($_POST["page"]-3)>0) {
if($_POST["page"] == 1)
$output = $output . '<span id=1 class="current-page">1</span>';
else
$output = $output . '<input type="submit" name="page" class="perpage-link" value="1" />';
}
if(($_POST["page"]-3)>1) {
$output = $output . '...';
}
for($i=($_POST["page"]-2); $i<=($_POST["page"]+2); $i++) {
if($i<1) continue;
if($i>$pages) break;
if($_POST["page"] == $i)
$output = $output . '<span id='.$i.' class="current-page" >'.$i.'</span>';
else
$output = $output . '<input type="submit" name="page" class="perpage-link" value="' . $i . '" />';
}
if(($pages-($_POST["page"]+2))>1) {
$output = $output . '...';
}
if(($pages-($_POST["page"]+2))>0) {
if($_POST["page"] == $pages)
$output = $output . '<span id=' . ($pages) .' class="current-page">' . ($pages) .'</span>';
else
$output = $output . '<input type="submit" name="page" class="perpage-link" value="' . $pages . '" />';
}
}
return $output;
}
function showperpage($sql, $per_page = 10, $href) {
require_once("../test/dbcontroller.php");
$db_handle = new DBController();
$rank = $db_handle->numRows($sql);
$perpage = perpage($rank, $per_page,$href);
return $perpage;
}
?>
Weiß einer vieleicht woran das liegen könnte? Danke im vorraus schonmal für die Hilfe.