Added function to generate pagination for mysql results