I'm trying to create a pagination script using a MSSQL database. I think I'm half way there, but finding limited resources to help get it finished up.

So far, I can output the limited results and set the page numbers correctly. However, the next pages contain the same data.

If somebody could take a look at this for me and let me know where I'm going wrong, that would be great.

PHP Code:
<?php 
$sth 
$dbconn->prepare ("SELECT     TOP (5) a.id, a.title, a.text, a.country, a.city, a.cat, a.user_id, a.use_ad, a.viewcount, a.tags, a.status, a.mod_status, publication_issue.img, 
                      publication_issue.publication_id, publication_issue.issue_number, publication_issue.upload_date, publication_issue.cat AS Expr1, 
                      publication_issue.viewcount AS Expr2, publication_issue.status AS Expr3, publication_issue.mod_status AS Expr4, publication_issue.user_id AS Expr5
FROM         (SELECT     TOP (75) id, title, text, country, city, cat, user_id, use_ad, viewcount, tags, status, mod_status
                       FROM          publication
                       ORDER BY id) AS a INNER JOIN
                      publication_issue ON a.id = publication_issue.publication_id
ORDER BY a.id DESC"
); 

$sth->execute();

while (
$results $sth->fetchAll(PDO::FETCH_ASSOC)){
//use $results
    
$pages ceil(count($results)/4); 
    
$page  = (isset ($_GET['page']))  ? (int) $_GET['page'] : ;
    
$start = ($page 1) *  $per_page



foreach (
$results as $row){

echo 
"title: ".$row['title']."<br />";

}




}
    
?>
    <br><br>
    <?php
    
if ($pages >=  && $page <= $pages){
    
//if ($page>1 && $page <= $pages){$previous=($page -1); echo '<a href="?page=' .$previous. '">Previous</a>';}
    
for($x=1$x<=$pages$x++){ echo ($x == $page) ? ' <strong><a href="?page='.$x.'">'.$x.'</a></strong> ' ' <a href="?page='.$x.'">'.$x.'</a> ';}
    
//if ($page>1  && $page <= $pages){ $next=($page+1) ; echo '<a href="?page=' .$next. '">Next</a>';}
    
}






?>