Database Performance

I have a question about pulling 1000’s of records from a database and efficiently displaying them.

My record set has 5000 records and I want to display it using HTML.  It would not be right to make a table with 5000 rows becuase it would take a long time and scrolling would be out of control.  So I want to only write the first 50 to the screen and have previous and next buttons to bring up the next or previous set of 50 records.  I know this is done all over the net(this site does it with these forums).  How do I do this?  Are there different options?

Thanks,