The doctor will probably Xray your knee or maybe do an MRI. I've had problems with my knees for years. Lately, the left one has been becoming dislocated (this was my GOOD knee, too). Both of my knees crunch and crack when I bend them. It turns out that this is because the groove that the kneecap is supposed to slide in is more shallow that for most people, and the kneecap slides in and out strangely. As they do for most knee issues, they suggested a bunch of exercises for me to do to strengthen the knees. So far, they still hurt.
Relax... I'll need some information first. Just the basic facts - can you show me where it hurts?