in reply to MySQL problems

It's rather unclear to me where your problem actually lies. Are you wondering what SQL to issue? Are you wondering how to format your output? I'm not sure what part of the architecture you mean. Do you mean small parts, like how to pass parameters to DBI? Do you mean large parts, like how to pass the information about what page to show between requests from the user(s)?

Often, it helps to show a very short, self-contained program that shows what you have. It shouldn't be hard to reduce your program to, say, 20 lines that show what you have, and to also tell us how it is not all you want.