It sounds llike the problem is not with his extremities (legs) but in his back or neck. Dogs can have problems with sprains and strains like people. Also dogs can develop ruptured intervertebral disc problems along their spine. Arthritis can also develop along the spine. Your dog needs to be examined by a veterinarian to localize the source of his pain, may need x-rays taken, and will be placed on pain medication. Before your appointment keep your dog activity restricted--no running, jumping, or playing. He should go out on short leash walks only to urinate and defecate. Do not allow him to jump on or off of your bed.
Have checked if he has got something stuck in his paw like a small piece of glass or a stone if not it could be very painful if you don't check his nails. Or if you can't find anything TAKE HIM TO A VET. Hope he gets better.