The closer an object is to the sun, the stronger the force of gravity is. In addition to the eight planets, there are several other objects that orbit the sun, including dwarf planets (like Pluto and Eris), asteroids (with a large amount found in the asteroid belt, which is located between Mars and Jupiter) and comets (with most found beyond the orbit of the planets in an area called the Oort Cloud).
The amount of time it takes a planet to complete one full orbit around the sun (also known as a revolution) depends on the planet's distance to the sun. Earth takes one Earth year; in contrast, Mercury, the closest planet, orbits around the sun in 88 Earth days, while Pluto takes around 248 Earth years to finish its revolution. Planets do not orbit around the sun in a perfectly circular fashion, but instead often take unusual orbits, such as the Earth's elliptical-shaped revolution.
The theory of gravity was originally proposed by Isaac Newton. Newton summed up the affect of gravity between two objects in the equation F = G(M1M2)/R, with "G" being the gravitational constant, "M" being the mass of the two objects considered and "R" being the radius between the two objects; thus, the more massive an object is, the stronger the force of gravity. The sun is so incredibly massive in comparison to other objects in the solar system that it holds many objects in its gravitational field, even the distant planets and comets.
Newton's conception of gravity was only a description of how it worked, not why it worked. Albert Einstein's General Theory of Relativity (published in 1915) showed that gravity is not caused directly by an object exerting a force on another object, but it is instead caused by curves in space-time. While Newtonian physics still was applicable for the solar system, Einstein's theory opened up the possibility of incredible objects like black holes, which is a point so dense in space that nothing, even light (which has no mass), can escape its gravitational field.