Hi,
both are somewhat older models. However, in terms of performances, features, controls, etc, the K20D wins hands-down. It is a larger camera, which is one of the only points it loses versus the K-x. It is weather sealed, with more external controls, a larger and brighter viewfinder, a top LCD, more resolution, a faster burst mode. It shows the focus point in the viewfinder, which is important too.
The L-x has a basic video mode, a few functions like in-camera HDR, a slightly faster max shutter speed, and that's about it.
Pentax Cameras | Pentax K20D vs. Pentax K-x vs. Pentax K-50 - Pentax DSLR Comparison - PentaxForums.com