First you need to know that the DPI setting within a digital photo is meaningless in the context of the digital photo itself. You'll understand the fact that a digital photo of say 3,000 x 2,000 pixels with the DPI set to 72 is identical to that same digital photo with the DPI set to 300 (except for those two DPI numbers in the photo). If the only change to those photos was to change the DPI number, then the photos are identical in both size and quality. But, to clarify, let's do some simple arithmetic.
DPI/PPI Printed Size
When a print shop or magazine asks you for a "300 dpi" photo, that request in itself is absolutely meaningless (there is no such thing as a 300 dpi, or any dpi digital photo). What they are asking for is a photo that will print at 300 pixels per inch (and this has nothing directly to do with the DPI setting inside the photo). To know if you have a suitable digital photo for that purpose, you need to know their intended output. If they tell you they need a digital photo that can print at 300 ppi to 7 inches by 5 inches then you can do the math.
300 ppi x 7 inches = 2,100 pixels and 300 ppi x 5 inches = 1,500 pixels.
So, if you have a digital photo that is greater than or equal to 2,100 x 1,500 pixels, then it will print on a 7" x 5" sheet at 300 ppi or greater.
We can turn this upside down and ask - if I have a 3,000 pixel wide digital photo and print it at 7 inches - what is the ppi? It's just 3,000 divided by 7 inches = 428.6 ppi. If you print that same photo to 11 inches, it will be printing at 272.7 ppi. It's just simple arithmetic.
To clarify that the DPI setting inside the photo is meaningless in terms of the digital photo itself, if it was set to 300 and you printed the 3,000 pixel wide photo at 7 inches, it will still be printing at 428.6 ppi. It's only meaningful if your software uses it to set the output dimensions, in which case your 3,000 pixel photo will print at 10 inches (at 300 ppi). But if you set the internal DPI of that photo to say 150 (without re-sizing the photo), and printed it at 10 inches, it will still be printing at 300 ppi.
DPI/PPI Digital Size
The size of a digital photo is its pixel dimensions. But how big will it print to paper? Say you have a 3,000 x 2,000 sized digital photo. Let's do the math:
At 300 ppi it will print at 10" x 6.7" (3,000/300 and 2,000/300)
At 200 ppi it will print at 15" x 10" (3,000/200 and 2,000/200)
At 100 ppi it will print at 30" x 20" (3,000/100 and 2,000/100)
DPI to PPI when scanning
This is very simple - 1 scanner "dot" = 1 pixel. So if you scan say a 7" x 5" photo at 400 dpi, you'll end up with a 2800 x 2000 pixel size digital image.
The resolution of a digital photo are its pixels. The more pixels that cover a specific area, the greater the digital resolution. This is ppi in reverse, that is, the number of pixels that resolve a certain feature. For instance, say you take a picture of a 20 foot wide billboard. If your digital photo is 2,100 pixels wide, then it will be "resolving" 8.75 pixels per inch (2,100 pixels / 240 inches = 8.75 pixels). In other words, each pixel will represent 0.11 inches of the billboard. If you take the same photo with a camera that creates 6,000 pixels, then it will be resolving 25 pixels per inch. Each pixel will now represent 0.04 inches of the billboard. With more pixels per inch of resolution, more details will be seen and those details will be crisper. A working example today is Google Earth - some sections are covered with higher resolution digital imagery than others. Some some views of the earth are sharp (more pixels) others are blurry (less pixels).
The figure of 300 ppi to archive "photographic" quality has been somewhat badly abused - it really depends on the intended output. Output quality from a digital photo is both subjective and non-linear. In terms of subjective - a photo that you send to your relatives need not be as high quality as one for an art magazine. In terms of linearity, a 300 ppi photo is not 2 times the quality of a 150 ppi photo - it's perhaps 30% better (or someone else might say 55% better). Viewing distance is also a factor, a poster (say 4' x 5'), meant to be viewed from a distance of several feet, may only require 75 ppi, whereas that same image printed at 4" x 5" may require 250 ppi to achieve the same subjective quality (since it's meant to be viewed at a distance of 1 foot rather than 6 feet).
Pixels to DPI or LPI
The printer world works in dots per inch or lines per inch depending on the equipment. They will take your RGB digital photo and convert it to a CMYK printed photo (see color models for explanation of RGB and CMYK). This involves software to rasterize the photo and convert it to CMYK and physical equipment to print it. The printer/magazine should be the ones best aware of the quality of their software and equipment and know how well it can physically print a digital photo. While many stick with the mantra of 300 ppi, the better ones will have evaluated their equipment and will let you know what minimum pixel size of digital image they require.