You're going to have to figure it out, but it's not that hard.

Number of pages needed = ceil(mysql_num_rows() / 5)
Then just keep track of the current page and the starting number.