views:

136

answers:

1

I'm a PHP learner. I am pulling rows from a db and displaying them in a very simple HTML table. Each row begins with a checkbox. There are 20 records on each page, and there are 5 pages. Every time I go to the "next page", the values in the $cVarString below are vacated. No page-to-page persistence. If I choose 10 rows on one page and 2 on the next page, $cVarString only contains the most recent 2 values. Why no persistence?

if ( isset ( $_POST [ 'checkbox' ] ) )
   {
      $cVarString .= implode ( ",", $_POST [ checkbox ] ) ; ;
   }

I guess I need to insert the values of $_POST into a table after selections are made on each page, so that I can have all the rows selected in one session. Is that right? Thanks!

+1  A: 

The web is "stateless" meaning you have no intrinsic way to maintain the state of your program. You need to use other methods to do this. Since you already have a DB, you might want to write the page data back to the DB then read it in on the next page. Another method is to use cookies, or sessions both of which have very good API support in PHP.

Jeremy Petzold
Thanks! Would you happen to know of any tutorial or reading materials that illustrate using my scenerio above with sessions? None of my PHP books seem to go into this specifically (i.e., using checkboxes, pagination, sessions, without going into OOP).Thanks again.
dave
none regarding your specific issue.
Jeremy Petzold