Storing checkbox selections between record paging

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I have results being displayed each with its own checkbox name
"selected[]" and value "id".

When someone checks a checkbox, and then continues to page through the
data (mysql select), I want that checkbox to be remembered.  Basically
I want the user to have multiple selections of checkboxes when paging
through data (recordset), then they click a "continue" button, it
takes all those values which are checked (over all the pages) and does
its thing (insert into a database).

One way I thought of is a JavaScript onClick each time a checkbox is
ticked, it adds it to an array, then uncheck would delete it from that
array.  I'm just not sure how I'd get that javascript array through to
PHP.  It sounds overly complicated.

Another way is running a query every time a page is loaded.  So on the
pageing buttons, I force the form to submit each time, writing that
pages data into a PHP $_SESSION array.  But I dont know how to
differentiate when the page buttons are submitting the form or when
the button is submitting the form, and I figured there must be an
easier way.

Kind regards

Site Timeline