I wanted a good flat and level workspace to continue projects. This workbench folds up to the wall in my garage so I can still park when not working on anything. I made it pretty stout with 2x4s and 2x6s since it would need to support fairly large pieces of furniture without deflecting. It is very heavy as a result though (good core workout folding it up and down :) )
I used two folding shelf brackets on the legs to keep them from accidentally being kicked out from under the table while it's out. (http://www.woodcraft.com/Product/2001690/2615/Folding-Shelf-Bracket-8-P…)
I used four heavy strap hinges to connect the table to the 2x6 (which was lag screwed into studs). Two gate latches were used to secure the edge of the table to studs when the table is folded up.
I cut the legs approximately, and then when the table was hung I cut and shimmed them to get the table level on the uneven surface of the garage floor.