How do I add a pager for the following code?
I think you are trying to do a custom pager, not based on db query something like this, but it is D6 code.
For D7, check Extenders and what the Database Abstraction Layer page describes is


  Most Drupal database SELECT queries are performed by a call to
  db_query() or db_query_range(). Module authors should also consider
  using the PagerDefault Extender for queries that return results that
  need to be presented on multiple pages


You may also need to check theme_pager which displays the pager result.
When calling theme('pager') outside a pager query, it's necessary to initialize the pager first with a call to pager_default_initialize.