Hey all,
Forgive me. I have given it my best for two long days now to wrap my tiny brain around this one, and after half a dozen tutorials, hours of searching and reading and agonizing trial and error I am completely stumped. What would be the shortest path at this juncture to enable "simple" Previous and Next links in the following script? I have pared down the results table for posting, but otherwise it's pretty close to what I want (of course updates will be my next obstacle, but one-thing-at-a-time `cause I'm kinda slow) if I could just get Previous & Next links to dynamically update the variable $screen+/-1... well... geeeze that would sure be just great!!!!
<html>
<body>
<?php
// database connection stuff here
require_once ('../mysql_connect.php');
mysql_select_db ('bike_shop');
$rows_per_page = 1;
$sql = "SELECT * FROM catalog";
$result = mysql_query($sql);
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);
if (!isset($screen)) $screen = 0;
$start = $screen * $rows_per_page;
$sql = "SELECT * FROM catalog ";
$sql .= "LIMIT $start, $rows_per_page";
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$record=mysql_result($result,$i,"id");
$product=mysql_result($result,$i,"Product");
$descripton=mysql_result($result,$i,"Description");
$price=mysql_result($result,$i,"Price");
$active=mysql_result($result,$i,"Active");
$deleted=mysql_result($result,$i,"deleted");
$disp_count=($screen+1);
echo "
<form>
<div align='center'>
<table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='57%'>
<tr>
<td> $product,$description,$price,$active,$deleted</td><td>Viewing $disp_count of $total_records </td>
</tr>
</table></div>
</form>";
}
echo "<p align='center'>\n";
// dynamic Previous & Next links here??
// dynamic Previous & Next links here??
// dynamic Previous & Next links here??
if ($screen > 0) {
$url = "example.php?screen=" . ($screen-1);
echo "<a href=\"$url\">Previous</a>\n";
}else if ($screen < $pages) {
$url = "example.php?screen=" . ($screen + 1);
echo "<a href=\"$url\">Next</a>\n";
$screen=($screen+1);
echo "</p>";
}
?>
</body>
</html>