The bike shop should be able to get you positioned correctly on the bike as part of the deal when you buy it. If they don't:
1. First measure your inseam (inside leg if you're in the UK) with your feet about 6" apart and your heels against a wall. Multiply the measurement by .883. That is a good starting point for the distance from the middle of the bottom bracket to the seat measured up the seat tube.
Then set up your fore/aft seat position, using a plumb-line. When sitting on the bike in a trainer drop the plumb-line from the little bump just below the knee with the pedal in the 3 o'clock position (12 o'clock is with the pedal at the top...) The plumb-line should be directly above the pedal axle for a starting position.
You may have to tweak the seat height slightly after this step.
Once the seat is set up correctly you can set up the reach to the handlebar by changing the stem to get the correct length. Don't move the seat to achieve this! What you're looking for is to set the handlebar a couple of inches lower than the seat, and in a position that feels comfortable with your hands on the brake hoods, which is where you'll spend the majority of your riding time.
A licensed cycling coach can get you set up correctly, generally for a modest fee.
2. Don't buy cheap - look for good value. A Shimano 105 groupset is fine for a start though an Ultegra or Chorus is certainly better. You do get 10 speeds with the Chorus, rather than 9 speeds on the cassette with Shimano.
3. Just ride. Don't worry too much about formal training for a few weeks, just enjoy the bike and the ride. The Lance Armstrong Performance Program book by Lance Armstrong and Chris Carmichael is a good investment and will get you started on a program - but get 4 weeks or so in your legs first.
4. With a knee problem you'll need to use easy/light gears at first and spin the gears at a cadence of 85 - 95 rpm without putting too much pressure on the pedals so you don't injure the knee further. Don't "mash" or power up hills at low cadences because that's very hard on the knees.
Enjoy your riding!