You need a KVM(Keyboard, Video, Mouse) switch. I have no experience with one so can't give any advice.
Online shopping for KVM Switches from a great selection at Computers & Accessories Store.
www.amazon.co.uk
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.