As a developer, this is not a good idea to have next/prev button controlling queries to a db.
Also, in a real world scenario, this could become a drag on performance on the DB Server.
Most prev/next functionality should be handled by the client, for example, the scroll bar. What you see is only a finite number of rows, the rest is in the client ...