if two organisms are in the same class then they will be in the same phylum. The biological classification hierarchy is arranged in such a way that, two organisms who belong to a lower division on the hierarchy will automatically be in the same group in the higher division.
The arrangement from the smallest to largest hierarchy is this: specie, genus, family, order, class, phylum and kingdom.