All the last / next link tutorials I've read involve a design where people want the viewer to browse. So if you had a bunch of books and an author, the tutorials teach me how to query by author and then display a certain amount of her books per page. However, what if you want to display info by book?
Specifically...
I have two tables in a comic book database:
cap_titles
TitleID
Title
Series
etc.
cap_issues
IssueID
TitleID - links to titles table
Issue
Additional
etc.
So with those two queries, I list various issues using the "IssueID", so viewers can go directly to the issue in question and read about it.
<?php
if ($IssueID)
{
$sql = "SELECT * FROM cap_titles, cap_issues
WHERE cap_titles.TitleID = cap_issues.TitleID
AND cap_issues.IssueID = $IssueID";
$result = mysql_query($sql,$db);
$num = mysql_num_rows($result);
$cur = 1;
while ($num >= $cur)
{
$row = mysql_fetch_array($result);
$Title = $row["Title"];
$Series = $row["FromDate"];
$Issue = $row["Issue"];
echo "$Title ($Series) #$Issue<P>";
$cur++;
}
}
else
{
echo "Awwww, you're mother! >:)";
}
?>
Example: http://www.livinglegend.org/test.php?IssueID=1
Now, in addition to this ability to allow viewers to go directly to their issue of choice, I think I want to provide a last / next link, but I can't wrap my head around how to do it. Maybe I could somehow tell PHP to plus or minus the issue number being displayed ($Issue), but sometimes the next issue in line is the same as the issue before it. (i.e., #1, #1A, #1B, #2, #3, etc.) So I probably need to tell PHP to pull the IssueID of one result less / one result more than the issue it's currently on. But I'm not sure how to do that. Something like:
SELECT * FROM cap_titles, cap_issues
WHERE cap_titles.TitleID = cap_issues.TitleID
AND cap_issues.IssueID = [1 result less than $result]
???