How to use next() and prev() on an array
Does anyone know how to get next(), prev(), and current() to work properly? I have tried it on what seems like a simple application but no luck.
I have a table of art titles with title_id as the index. When someone clicks on a thumbnail it takes them to a detail page for that painting using the title_id in the query string. On the detail page I have NEXT and PREVIOUS arrows so people can browse to new paintings without returning to the thumbnail page. I want the array to be defined as
Code:
SELECT * FROM title WHERE artist_id=1 ORDER BY title
so that when they click NEXT it will take them to the next painting by that artist in alphabetical order by title. I haven't been able to get it to work so am currently using title_id + 1 and title_id -1, which is unsatisfactory. Seeing as the page is selected using the title_id, as in <a href="/php/art-detail.php?title_id=<?php echo $title_id +1;?>, how do I bring the array into it so next and prev work?
I have considered separating the artists into separate tables but that seems like settling for failure. I'd rather do it properly. This can't be that hard. I must be making some error I just can't see. Please put me out of my misery. Thanks! e :)