Tableselect element
The form element tableselect provides a clean, easy way to create tables with one checkbox per row, multi-row selection and a select all checkbox, without making your code a complicated mess:
Update: This book is about the tableselect element provided by the Elements module for Drupal 5 and 6. See A new form element in Drupal core for a HOWTO on the new Drupal 7 form element.