I am working on some PHP / mysql 5 web project involving a database table that uses not indexed GUID strings as its identifier for rows. So the rows of this product table look like this:
GUID Name
936DA01F-9ABD-4d9d-80C7-02AF85C822A8 Product 1
07c5bcdc-b3a6-482f-8556-bb04fae06538 Product 2
b7b39700-d0e2-11de-8a39-0800200c9a66 Product 3
The new requirement is, when I am on the details page of Product 2, this page should contain a previous link (pointing to Product 1) and a back link pointing to Product 3.
Finding Product 2 is easy:
SELECT * FROM products WHERE GUID = "07c5bcdc-b3a6-482f-8556-bb04fae06538"
But how would I find the GUIDs of the previous and next products?
Remember: The product table has no auto-increment column and I cant add one easily as I am not in control over the database …
EDIT:
The records are ordered by a timestamp column.
I am confused ….
Regarding the answer from Jeff; If the product has no naming schema (random?) how are the products sorted in the output to the pages?
If the output to the pages are sorted by timestamp only, then the answer from Jeff can be used with a small alteration of the where clause:
and the other one:
Or use the GUID from ‘Product 2’:
and the other one:
Regards
Sigersted