The "best" way to do it, provided the tables are all the same would be to use PHP. It would dramatically cut down you code.
By using a variable to hold frequently used code and then pulling the variable as needed you could make a whole table in just 1 line of code each.