Was the Mexican war before the Civil war?

Yes. The Mexican War ended about thirteen years before the Civil War began.