Excuse me for not formating my question correctly. Hopefully it is formated correctly now. My question is still unanswered form the previous post.
I took your code and replaced it with my code. The result is seeing all entries (not 5 at a time as desired) and the pagination links do not link to the NEXT or PREV pages.
I appreciate your response and help.
Here is my code.
<?php
$db = odbc_connect('',''','''); //put your connection here
function inv_rows($r1) {
ob_start();
(int)$number=odbc_result_all($r1);
ob_clean();
return $number;
}
$page = isset($_POST["page"]) ? $_POST["page"] : 1;
if(empty($page)){$page = 1; }
$query = "SELECT * FROM plastic"; // name of table is plastic with columns plastic_ID, ename, and iname.
$num_result = odbc_exec($db, $query);
$numrows = inv_rows($num_result);
echo '<p>There are '.$numrows.' ideas.</p>';
$limit = 5;
$limitvalue = $page * $limit - ($limit);
$limitnew = $limitvalue + $limit;
if (isset($_POST['submit'])) {
switch ($_POST['direction']) {
case 'next':
$query = "SELECT TOP 5 * FROM plastic WHERE plastic_ID > " . $_SESSION['lastid'] . " ORDER BY plastic_ID";
break;
case 'prev':
$query = "SELECT * FROM (SELECT TOP 5 * FROM plastic WHERE plastic_ID < " . $_SESSION['firstid'] . " ORDER BY plastic_ID DESC) AS t ORDER BY plastic_ID ASC";
break;
default:
$query = "SELECT TOP 5 * FROM plastic ORDER BY plastic_ID";
}
}
$result = odbc_exec($db, $query);
while(odbc_fetch_row($result)){
?>
<table style="width: 600;">
<tr>
<td style="width: 300; height: 25px;">Name:</td>
<td style="width: 300; height: 25px;">Idea Name:</td>
</tr>
<tr>
<td style="width: 300; height: 25px;"><?php echo odbc_result($result, "ename"); ?></td>
<td style="width: 300; height: 25px;"><?php echo odbc_result($result, "iname"); ?></td>
</tr>
<tr>
<td colspan="5" style="height: 25px"><hr/></td>
</tr>
</table>
<?php //PREVIOUS AND NEXT BUTTONS
}
if($page !=1){
$pageprev = $page - 1;
echo " <strong><a href='?page=$pageprev'>PREV</a></strong> "; }
else{ echo " PREV "; }
$numofpages = $numrows / $limit;
for($i = 1; $i <= $numofpages; ++$i){
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</a></strong> "; }
}
if(($numrows % $limit) != 0){
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</strong></b> "; }
}
if(($numrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo " <strong><a href='?page=$pagenext'>NEXT</a></strong> "; }
else{ echo " NEXT "; }
odbc_free_result($result);
exit;
?>