This photo shows the electric guitar pickups from a Fender Stratocaster. Notice that there are three different pickup locations, and each location has a pickup (the circular dots) for every string. Each individual pickup contains a magnet, a coil, and thousands of turns of insulated wire wrapped around the magnet.
To find out how an electric guitar produces sound from a vibrating string, see Hyperphysics: Electric Guitars. To learn about the physics of vibrating strings, see this additional Hyperphysics page.