PHP sequential numbering

Soltalostuple

New Member
I'm having trouble with my page here:LINKMy "rank" part of the table keeps resetting back to zero when you click on page 2 and beyond. It doesn't start at 21, it just resets back to zero.How do I fix that?\[code\]<?php include ("database.php");if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 20; $sql = ("SELECT * FROM voting ORDER BY votepoints DESC LIMIT $start_from, 20") or die ("Error 1."); $rs_result = mysql_query ($sql) or die (include ("error.html"));$rank = 1;?> <table><tr><td>Rank</td><td></td><td>Username</td><td></td><td></td><td></td><td>Vote points</td></tr><?phpwhile ($row = mysql_fetch_assoc($rs_result)) { ?> <tr> <td><? echo $rank++; ?></td> <td></td> <td><? echo $row["username"]; ?></td> <td></td> <td></td> <td></td> <td><? echo $row["votepoints"]; ?></td> </tr><?php }; ?> </table><?phpecho '<br>';echo 'Total Votes: ';include ("sum.php");include("database.php");$sql = "SELECT COUNT(votepoints) FROM voting"; $rs_result = mysql_query($sql);$row = mysql_fetch_row($rs_result);$total_records = $row[0];$total_pages = ceil($total_records / 20);echo '<span class="text-bleumarin">';if($page>1)$pagelink ='<a href="http://stackoverflow.com/questions/3858382/votes.php?page='.($page-1).'">prev</a> ';echo $pagelink;for ($i=1; $i<=$total_pages; $i++) {if ($i != $page)echo "<a href='http://stackoverflow.com/questions/3858382/votes.php?page=".$i."'>".$i."</a> ";if ($i==$page)echo '' . $i . ' ';};if($page<$total_pages)$pagelink ='<a href="http://stackoverflow.com/questions/3858382/votes.php?page='.($page+1).'">next</a> ';echo $pagelink;echo '</span>';?>\[/code\]
 
Back
Top