Posiadam ranking graczy
Jest około 3 000 wpisów
Wyświetlanie ich wszystkich na 1 stronie powoduje bardzo długie ładowanie strony oraz jej słabą przejrzystość.
Dodałem paginację. Na każdej stronie pokazuje 50 wyników przesortowanych według najwyższego wyniku z kolumny "score"
Problem:
Na drugiej stronie pozycja w rankingu powinna być ponumerowana już od 50-100 a jest od 1-50 i tak na każdej stronie.
Kod PHP:
$query = "SELECT COUNT(*) as all_posts FROM `$bd_table`"; $onpage = 50; $navnum = 7; if(!isset($_GET['page']) or $_GET['page'] > $allpages or !is_numeric($_GET['page']) or $_GET['page'] <= 0){ $page = 1; }else{ $page = $_GET['page']; } $limit = ($page - 1) * $onpage; $query1 = "SELECT * FROM `$bd_table`ORDER BY score DESC LIMIT $limit, $onpage"; echo "<table id='table'><tr><th>Poz.</th><th>Nick</th><th>SteamID</th><th>Punkty</th><th>KDR</th><th>HS</th><th>Celność</th><th>Profil</th></td>"; $rank=0; $rank++; if($row['hits'] == 0){ $hits = 1; } else { $hits = $row['hits']; } if($row['deaths'] == 0){ $deaths = 1; } else { $deaths = $row['deaths']; } if($row['shots'] == 0){ $shots = 1; } else { $shots = $row['shots']; } $accuracy = ""; $accuracy .= ""; }else{ $accuracy = $accuracy . $temp[$i]; } } } else { $accuracy = $temp . ".00";} echo "<tr><td>$rank</td><td>" . $row['name'] . "</td><td>{$row['steam']}</td><td>{$row['score']}</td><td>"; break; }else{ } } <td><a href='showplayer.php?id=".$row['id']."'><img src='images/more.png'></a></a></td> </tr>"; } if($navnum > $allpages){ $navnum = $allpages; } $forend = $forstart + $navnum; if($forstart <= 0){ $forstart = 1; } $overend = $allpages - $forend; if($overend < 0){ $forstart = $forstart + $overend + 1; } $forend = $forstart + $navnum; $prev = $page - 1; $next = $page + 1;
Dziękuje za pomoc.