I was working on a site today and needed to code a pager (the query was too complex for views). The most logical thing (which I looked for) was a tutorial on coding pagers in Drupal. Unfortunately, I was unable to find one, so I'll post a tutorial here.
