Lets say i have a databse:
+----------+
| Database |
+----------+
| id |
| image |
| category |
+----------+
Now i have a page that shows an image from the database, i want to add a
<< Previous image
and
Next image >>
button. I could just take the $id and add +1 , but what if the next ID does not exist in the DB ?
Any help appreciated, thanks
So i found this:
SELECT *
FROM database AS c
WHERE (id = (SELECT MAX(id) FROM database WHERE id < c.id AND language = 'en')
OR id = (SELECT MIN(id) FROM database WHERE id > c.id AND language = 'en'))
But how do i make a link out of it, like:
<a href="domain.com/$c ??">Next</a> ?
You’ll have to use another select: