I am trying to do a dynamic paging for my mySQL database. Results per page are 20, and the number of pages (displayed at the bottom) is dependent on $totalPages
I am currently having some trouble escaping strings after the for-loop. Can someone help me double check?
$result = mysql_query("SELECT COUNT(0) FROM Spreadsheet");
$rows = mysql_fetch_array($result);
$total = $rows[0];
$totalPages = ceil($total/20);
$i=0;
$pages = "Pages :";
echo $pages;
for ($i; $i<$totalPages; $i++){
echo "<a href=\"index.php?page='$i'rpp=20\">$i</a>";
}
The results should look like this:
Pages: 1, 2, 3, 4, 5, etc..
Thank you for the help!
1 Answer