Is your pagination code inside the loop or outside?