It is not clear on my part when I get partial code back from you to put it in the correct place. It might be helpful if the entire code with updates was returned. I am having trouble putting it all together when it is returned.
The code below has error: Undefined index: submit on line 21.
Thank you in advance for your help.
<?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;
$max = 5; // Number Results/Page
$start = 6; // This would be the where you start
$perpage = 5;
if ($_POST['submit']) {
$page = $_POST['page'];
$top = ($page - 1) * $perpage;
$sql = "SELECT TOP $perpage * FROM plastic WHERE plastic_ID NOT IN (SELECT TOP $top plastic_ID FROM plastic ORDER BY plastic_ID) ORDER BY plastic_ID";
}
$result = odbc_exec($db, $sql);
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;
?>