I'm following some example of PHP paging with ODBC on the internet and change them according to my own use.
I've managed to make to NEXT and PREVIOUS worked. The URL of the page change when the NEXT or PREVIOUS is clicked. For example when I clicked NEXT this is the URL localhost/mypage.php?page=2.
The issue here is the table of the data won't show up.
This is my code :
function inv_rows($r1)  
{
ob_start(); 
(int)$number = odbc_result_all($r1);
ob_clean(); 
return $number;
}
$page = isset($_GET["page"]) ? $_GET["page"] : 1;  
if(empty($page)){$page = 1; 
}           
$query = "SELECT UserId, UserNm FROM User"; 
$num_result = odbc_exec($db, $query);
$numrows = inv_rows($num_result);   
$limit = 10;
$offset = ($page - 1) * $limit;
$sql = odbc_exec($conn,"SELECT UserId, UserNm FROM User LIMIT $limit OFFSET $offset"); 
$result = odbc_exec($db, $sql);
echo "<table style='width: 600;'>";
while(odbc_fetch_row($result))
{
echo "<tr>
<td style='width: 300; height: 15px;>";
echo odbc_result_all($result, "UserId");
echo "</td>
<td style='width: 300; height: 15px;'>";
echo odbc_result_all($result, "UserNm");
echo "</td>
</tr>";
}
echo "</table>";
if($page !=1)
{
$pageprev = $page - 1;
echo "<a href='paging2.php?page=$pageprev' style='text-decoration: none'>  PREVIOUS </a>";
}
else
{ 
echo "  PREVIOUS  "; 
}
if(($numrows - ($limit * $page)) > 0)
{
$pagenext = $page + 1;
echo "<a href='paging2.php?page=$pagenext' style='text-decoration: none'>NEXT</a>"; }
else
{ 
echo "  NEXT  "; 
}
odbc_free_result($result);            
exit;
?> 
I'm sure I miss something. Please guide me. Thank you.
 
     
    