I'm new to this forum and haven't searched it nearly enough, so the solution to my query may already be here. Any pointers to such a topical thread(s) is greatly appreciated.
Here is the where the pages in question are being experimented with:
http://www.crsociety.info/misc/index.php
I'm trying to create Prev. Page | Next Page links on both:
The Category page (index to prev or next category page, if any exist, each of which contains a list of items)
The Product details page (index to prev or next product page, if any exist, in the order in which they are listed in the database (doesn't matter which category they belong to)).
The database was pre-sorted prior to being uploaded into MySQL. I would rather not sort dynamically. I also do not want to add any more fields (columns) to the database, though a programmer friend noted that I may have to add a unique id (auto increment) in MySQL.
Here are the fields in the database table book_items:
NAME varchar(255) not null default '',
NAME_clean varchar(255) not null default '',
CATEGORY varchar(50) not null default '',
CATEGORY_clean varchar(50) not null default '',
AUTHOR varchar(50) not null default '',
SIP varchar(50) not null default '',
ASIN varchar(50) not null default '',
Book_Description mediumtext not null default '',
Book_Description2 mediumtext not null default '',
Book_Description3 mediumtext not null default '',
Review1 mediumtext not null default '',
Review2 mediumtext not null default '',
Review3 mediumtext not null default '',
Review4 mediumtext not null default '',
Review5 mediumtext not null default ''
"ASIN" is an alphanumerical string (product code) unique to each item.
In an attempt to create the PREV | NEXT page links, a programmer friend suggested:
==========
To make prev / next links, when you build the link for the item, you also need to include (in the link) the information needed to make the link to the prev and next item. Then the page that displays the item also has the information needed to display the prev / next links. For example, if when generating the index page (list of all categories) output is:
A
B
C
D
Rather than just generating
href="...?q=cat&name=A"
href="...?q=cat&name=B"
href="...?q=cat&name=C"
href="...?q=cat&name=D"
You need to generate
href="...?q=cat&name=A&next=B"
href="...?q=cat&name=B&prev=A&next=C"
href="...?q=cat&name=C&prev=B&next=D"
href="...?q=cat&name=D&prev=C"
This requires modifying the
while($row = mysql_fetch_array($result)) {
} loop so that information for all three links (normal, prev, next) are available and can be used to make the link.
But this approach ran into a serious glitch, as friend comments:
==========
It works ok to generate the initial prev/next links. But then if the user clicks on one of those links to go to the next or prev item. There is no way to generate the prev/next links on that page because the info is not included in the url variables.
I think the best approach is add in the unique id (auto increment)....
Can anyone provide an alternative to this strategy -- one that works?!
Thx,
KH