You need to implement some kind of pagination here.
Usually, you take take a string query from the url for this for the page you want to filter to. Use that page number with an offset and limit to get a slice of the query for the given page.
I found a guide to achieve this relatively quickly, give this a try and tell me if this is what you are after or not or if you get stuck.
Also i edited your post to wrap code in the proper CODE tags, please use them in future so that your code is legible. BBTags are in all uppercase and in square brackets.