开发者

Persistence of checkbox data from 5-page html table display

开发者 https://www.devze.com 2022-12-20 05:34 出处:网络
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

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 开发者_JAVA百科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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号