Megan has given the answer to this to another reader, so have a look at that. Basically, your plants have "bolted" to seed, because they are too hot, thirsty, were not given enough fertilizer, or were transplanted too late or roughly and went into shock.
Of course if you already have good strong plants and stems, try cutting back the flower stalks and you may find new button heads forming around the sides.