Firstly, some results about the frequencies of phonons in wurtzite ternary mixed crystals (TMCs) fitted by several methods (modified random-element-isodiplacement model (MREI), virtual crystal approximation, and simplified coherent potential approximation, etc.) are compared. Then, combined with the continuous dielectric model and uniaxial crystal model, a fitting method available to experimental data is adopted to derive the dispersion relations of different kinds of optical phonon modes in TMC InxGa1-xN and AlxGa1-xN quantum wells. Furthermore, the variation of phonon modes dependent on the composition is analyzed. The results show that the fitting by the MREI for phonon frequencies of wurtzite TMCs with one-mode property agrees better with the experimental data. It can be also found that the optical phonon modes in quantum wells vary with the composition. The phonon modes, such as localized modes, interface modes, half-space modes, and propagating modes, exist in certain composition regions and frequency regions due to the anisotropy of phonon dispersion of wurtzite nitrides. Moreover, the shape of the same kind of phonon modes also varies with the composition.