|Start with the speedo cable attached to the transmission, and have the instrument end of the cable in view. Drive the car slowly. If you have an MPH speedometer, the cable should turn once per 5.28 feet of travel, and probably the same with the Km/H and dual scale (MPH-Km/H) types as well. If not, then (a) the cable drive gears in the transmission are bad, (b) the cable is bad, (c) the cable is not properly attached to the transmission, or (d) the transmission end of the cable is worn.
If the cable turns then the trouble is likely in the speedometer itself. Remove the instrument from the dash. Next, insert a speedo cable end, shaped wooden stick, wooden or cardboard Q-tip shaft, etc., into the cable input of the gauge, and turn it with a variable-speed electric drill. With a speedo calibrated at 1000 turns/mile, a drill speed of 1000 rpm will give an indication of 60 mph. If the speedo reads incorrectly, and you're certain the drill is turning at 1000 rpm, then the speedo is not currently calibrated for 1000 turns per mile. If the speedo does not indicate anything, or is erratic, it is in need of cleaning, repair or replacement.
If by chance the speedo does read correctly, then while the instrument is still disconnected from the dash, attach the speedo cable to the back and drive the car while watching the dial. If the speedo appears to be reading correctly, and does not fail or go erratic as you twist and turn it about, then the failure was a fluke of some sort; put everything back together and count your blessings.
On the other hand, if the speedo is dead at that time, or erratic, then (a) the inner section of the cable is too short for the outside sheath, (b) the square hole in the cable input of the speedo is worn, (c) the cable end is worn, or (d) wear forces disengagement of the speedo gears inside the transmission when the speedo cable is fully seated.
It's my understanding that the the speedo gear bits in the transmission are very rare, and if they turn out to be your problem, your only option may be to take the needed parts from a spare transmission.