here is what you do:
1. Unscrew the extension mechanism from the bottom of the table. Remove the part of the table you won't be using.
2. Sand the remaining part, then prime and paint it.
3. Nail or screw a two-by-two-inch piece of wood to the wall at the height of the tabletop so that the edge of the table rests on the wood support.
4. Screw through the top of the table to the wood support; fill the holes with wood filler, and paint over them.