+ connect to the database server
+ select the database
+ run the query to get a recordset
+ iterate through the recordset using a while loop and
inside the loop, echo the appropriate table tags with the content you want.
+ use css to control the table size and cell size.
you cannot, in php, cause the browser to print in landscape and you cannot rotate the table in php without converting it first to an image.