3 Replies - 253 Views - Last Post: 05 May 2012 - 06:34 AM Rate Topic: -----

#1 ktsirig  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 94
  • Joined: 14-September 05

Store multiple selection from pagination info into single array

Posted 04 May 2012 - 05:30 AM

Hi

I have a results page from a MySQL query and I have implemented pagination to present data in chunks of 25 per page in a table view (each row => 1 entry).

My problem is that next to each data row, I have a selection checkbox, and if the user clicks on it, he can download the selected entries. This thing worked OK before I employed paginated view, when I presented all data in one page. Now, if I select e.g. 2 entries in page 1, then I jump to page 12 and select another 2 entries, if I click on the "Retrieve" button, I get only the last 2 entries (from the last page visited).

How can I solve this problem? With JS? Can I use PHP only?

Is This A Good Question/Topic? 0
  • +

Replies To: Store multiple selection from pagination info into single array

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2486
  • View blog
  • Posts: 8,533
  • Joined: 08-August 08

Re: Store multiple selection from pagination info into single array

Posted 04 May 2012 - 06:03 AM

How could we know from the information provided? We know nothing of how your code is generating the HTML, or even what the HTML looks like.
Was This Post Helpful? 0
  • +
  • -

#3 hiddenghost  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 37
  • View blog
  • Posts: 599
  • Joined: 15-December 09

Re: Store multiple selection from pagination info into single array

Posted 05 May 2012 - 05:35 AM

PHP is just serving up the pages as html.

The form won't use information from a previous page before it's submitted.
When you switch the page it's just like closing the browser for the previous page.
You need to use some mechanism to store the previously selected information between pages.
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3048
  • View blog
  • Posts: 4,569
  • Joined: 08-June 10

Re: Store multiple selection from pagination info into single array

Posted 05 May 2012 - 06:34 AM

I would suggest using AJAX for something like this, or some sort of local storage.

Using AJAX, you would send a request to PHP every time a box is checked or unchecked so PHP can update the session with you choices. Then when you finally process the boxes, you can read them from there.

Using local storage, you would either set a cookie or use the HTML5 local storage API to store the selected boxes on the browser, and then send them to PHP when the user finally decides to send it.

The problem with the local storage option is that browser support is limited. Although, all modern browsers, even IE, support them now. - If you want to support older browsers as well, you could mix the two methods. Use local storage where available, or use AJAX when it's not. Then PHP can simply read the values from the session and take in more options from the request. (It'd have to do that in any case.)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1