Are you storing the url to the next page in the database or are you storing the image that you are wanting to load next in the database?
The general way to get this done is to create a recordset that returns the values stored in the database. After this, you can use recordset manipulation functions to get the values you want. Here is a quick tutorial on some of the functions:
recordset_movefirst.html