Q:

How to display results out of a loop (Perl cgi)

I have a question! I have built a cgi file which is doing the following:

a loop which querys a database
while rows are found, build an image and print it

Everything works fine. But now my Problem: if I find too many entries, I don't want to display them. For example: if my searchresult finds more then 50 rows, don't display them!
The pseudo code looks like this:
*while row is found*    
{

 *increase counter of found rows*

 *build and print image*

}

If I find more than 30 entries, the website will load awfully long (displaying all the images) and you have to scroll too much. Sometimes I find more then 600 entries and I don't want to display them at all! So I have to count them first and then make a decision if I want to see them or not.
But how can I display the rows AFTER I counted them? Because I can only print the rows within the while loop.

A:

Either use paging:
How can I do paging and sorting in a Perl CGI program?
Or use a fancy AJAX table to request n results, and have buttons for paging back and fourth between 'pages'

