Cardio Pulmonary Resucitation is the technique used to pump the heart, from the outside, so blood circulates carrying vital oxygen to starving tissue.
When someone collapses from a heart attack they literally only have a few minutes until body organs, especially the brain, starts dying from lack of oxygen. By performing CPR a rescuer can buy this person more time until the paramedics arrive
The latest standard is to perform 30 compressions to 2 breaths. These compressions should be done fairly quickly and with enough force to compress an adult's chest almost 5cm. The idea is to compress hard enough and fast enough to squeeze the heart so blood is pushed out, to create circulation. For a child or infant the compression depth should be between 1/3 to 1/2 of the child's/baby's chest depth. This needs to continue until paramedics arrive, or something changes with the casualty, at which point you reassess breathing. If a person is breathing, do not start CPR, but stay with them and monitor their condition until help arrives.
In a situation where the rescuer can not give breaths, compressions should still be started until help arrives. Compressions are more important, as they circulate blood, which will be oxygenated for several minutes. If a defibrillator is brought to the scene it should be used as soon as possible. Keep in mind that ribs may break with CPR, but it is important to keep going.
Below are some videos that will explain this a bit more. Remember, propere training is required.
Adult and Child CPR