I recently created a pagination script and its working nicely, but I am having issues displaying it where I want it to be. Here is the thing, I had to put the code above the where my data is being echoed because I have a while statement that needs the query to run before it. Because of this, the page links are displayed above the rest of my code. I am hoping there is a way that I can display the pagination at the end of my code instead. Here is the pagination code I am using in case it is needed:I appreciate any help on thisPHP Code:if($_GET['page']) { // Is the page defined?
$page = $_GET['page']; // Set page defined
} else {
$page = 1; // Default page is 1
}
$max = 1; // Max results on a page
$cur = (($page * $max) - $max); // Works out what results to show
$sql = "SELECT * FROM `users` ORDER BY `id` DESC LIMIT $cur, $max";
$result = mysql_query($sql) or die ('Error selecting users from the database!' .mysql_error());
$count_total = mysql_query("SELECT * FROM `users` "); // Get data from database
$count_total = mysql_num_rows($count_total); // Count lines in database
$total_pages = ceil($count_total / $max); // Total results divided by max to display
if($page > 1) { // Is the page # more than one?
$prev = ($page - 1); // If yes, take one away from current page
echo '<a href="?page='.$prev.'">Previous</a>'; // Echo link to previous page
}
for($i == 1; $i <= $total_pages; $i++) // For each page number
if($page == $i) { // If page = current page
echo '<b>'.$i.'</b>'; // Echo page in bold
} else {
echo ' <a href="?page='.$i.'">'.$i.'</a> '; // Echo link to the page
}
if($page < $total_pages) { // Is there another page?
$next = ($page + 1); // If so, add 1 to current page
echo '<a href="?page='.$next.'">Next>></a>'; // Echo next page link
}

