$rank++ in sub pagina's [probleem]
Ik weet niet precies hoe het heet, dus noem ik het maar "sub pagina's".
Als ik naar de volgende pagina wil, dan begint $rank++ weer vanaf 1, maar ik wil dat het blijft op tellen.
Hoe kan ik dit oplossen?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
if($data)
{
foreach($data as $row)
{
$rank++;
echo '
<tr class="'.$class.'">
<td style="text-align:right;padding-right:10px;">'.$getalletje.'</td>
<td><a href="stats.php?username='.$row['username'].'">'.$row['username'].'</a></td>
<td>'.number_format($row[''.$_GET['skill'].'_lvl']).'</td>
<td>'.number_format($row[''.$_GET['skill'].'_xp']).'</td>
</tr>
</tr>
';
}
echo '</table>';
echo '<ul class="pagination">';
if($pageNumberStart > 1)
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?page=1" title="pagina 1">...</a></li>';
for($i=$pageNumberStart; $i<=$pageNumberEnd; $i++)
echo $i == $currentPage ? '<li><strong>'.$i.'</strong></li>' : '<li><a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'" title="pagina '.$i.'">'.$i.'</a></li>';
if($pageNumberEnd < $totalPages)
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?page='.$totalPages.'" title="pagina '.$totalPages.'">...</a></li>';
echo '</ul>';
}
else
{
echo '<center><p>no users found.</p></center>';
}
?>
if($data)
{
foreach($data as $row)
{
$rank++;
echo '
<tr class="'.$class.'">
<td style="text-align:right;padding-right:10px;">'.$getalletje.'</td>
<td><a href="stats.php?username='.$row['username'].'">'.$row['username'].'</a></td>
<td>'.number_format($row[''.$_GET['skill'].'_lvl']).'</td>
<td>'.number_format($row[''.$_GET['skill'].'_xp']).'</td>
</tr>
</tr>
';
}
echo '</table>';
echo '<ul class="pagination">';
if($pageNumberStart > 1)
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?page=1" title="pagina 1">...</a></li>';
for($i=$pageNumberStart; $i<=$pageNumberEnd; $i++)
echo $i == $currentPage ? '<li><strong>'.$i.'</strong></li>' : '<li><a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'" title="pagina '.$i.'">'.$i.'</a></li>';
if($pageNumberEnd < $totalPages)
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?page='.$totalPages.'" title="pagina '.$totalPages.'">...</a></li>';
echo '</ul>';
}
else
{
echo '<center><p>no users found.</p></center>';
}
?>
Dan zal je het in een session moeten zetten.
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
$telling = $test++;
if($currentPage == 1){
$_SESSION['rank'] = $telling + $currentPage;
session_write_close();
}
if($currentPage > 1){
$_SESSION['rank'] = $telling + $currentPage + 2;
session_write_close();
}
if($currentPage == 1){
$_SESSION['rank'] = $telling + $currentPage;
session_write_close();
}
if($currentPage > 1){
$_SESSION['rank'] = $telling + $currentPage + 2;
session_write_close();
}
Al bugt het vanaf pagina 3.