title: checked checkbox will remain through pagination
body: <p>i am doing a php script wherein I need to remember the checked checkbox and save it all the database. Unfortunately, my code save only the current page where I checked the checkbox but the other checked box became unchecked. </p>
  
  <p>Example In Page 1 I checked 3 items, on the second page I checked I tem. When I click the submit button I only got the checked item of the current page. And when I go back to the previous page the item that I checked became unchecked.How can I preserved and save the value of my checked checkbox through pagination?</p>
  
  <p>here is my code for CreateTest.php</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;?php
  ob_start();
  session_start();
  include("connect.php");
  error_reporting(0);
  $item_per_page=10;
  $results = mysqli_query($con,"SELECT COUNT(*) FROM tblitem");
  $get_total_rows = mysqli_fetch_array($results); //total records
  
  //break total records into pages
  $pages = ceil($get_total_rows[0]/$item_per_page);   
  
  //create pagination
  if($pages &gt; 1)
  {
      $pagination = '';
      $pagination .= '&lt;ul class="paginate"&gt;';
      for($i = 1; $i&lt;=$pages; $i++)
      {
          $pagination .= '&lt;li&gt;&lt;a href="#" class="paginate_click" id="'.$i.'page"&gt;'.$i.'&lt;/a&gt;&lt;/li&gt;';
      }
      $pagination .= '&lt;/ul&gt;';
  }
  
  ?&gt;&lt;!DOCTYPE html&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $("#results").load("fetch_pages.php", {'page':0}, function() {$("#1-page").addClass('active');});  //initial page number to load
  
      $(".paginate_click").click(function (e) {
  
          $("#results").prepend('&lt;div class="loading-indication"&gt;&lt;img src="ajax-loader.gif" /&gt; Loading...&lt;/div&gt;');
  
          var clicked_id = $(this).attr("id").split("-"); //ID of clicked element, split() to get page number.
          var page_num = parseInt(clicked_id[0]); //clicked_id[0] holds the page number we need 
  
          $('.paginate_click').removeClass('active'); //remove any active class
  
          //post page number and load returned data into result element
          //notice (page_num-1), subtract 1 to get actual starting point
          $("#results").load("fetch_pages.php", {'page':(page_num-1)}, function(){
  
          });
  
          $(this).addClass('active'); //add active class to currently clicked element (style purpose)
  
          return false; //prevent going to herf link
      }); 
  });
  &lt;/script&gt;
  &lt;form name="myform" action="CreateTest.php" method="POST" onsubmit="return checkTheBox();" autocomplete="off"&gt;
  
  &lt;body&gt;
  &lt;?php 
  if(isset($_POST['save'])){
      $testPrice = $_POST['testPrice'];
      $testName = $_POST['testName'];
      $items = $_POST['items'];
      $quantity = $_POST['quantity'];
      $testDept = $_POST['testDept'];
      $measurement = $_POST['measurement'];
   global $con;
     Tool::SP_Tests_Insert(strip_tags(ucwords($testName)), $testPrice, $testDept);
      $result = mysqli_query($con, "SELECT MAX(TestID) FROM lis.tbltests");
      $data=  mysqli_fetch_array($result);
      $testID=$data[0];
      foreach ($items as $key =&gt; $value){
       $checkedItem[] = $value; 
      echo $value, " | ",$quantity[$key], " | ",$measurement[$key], "&lt;br&gt;";
       mysqli_query($con,"INSERT INTO tbltestitem (TestID, ItemID, ItemQuantity, ItemMeasurement) VALUES ($testID, $value, '$quantity[$key]', '$measurement[$key]')");
  }
  echo "&lt;script type='text/javascript'&gt;alert('Succesfully added test!')&lt;/script&gt;";
      $site_url = "tests.php";
      echo "&lt;script language=\"JavaScript\"&gt;{location.href=\"$site_url\"; self.focus();  }&lt;/script&gt;";
  
  }else if(!isset($_POST['save'])){
  $selectDept='';
  $result= mysqli_query($con,"select * from tbldepartment");
  $selectDept.="&lt;option value=''&gt;Select Department:&lt;/option&gt;";
  while($data = mysqli_fetch_array($result)){
      $selectDept.="&lt;option value='{$data['DeptID']}'&gt;{$data['DeptName']}&lt;/option&gt;";
  }
  ?&gt;
  &lt;td style="vertical-align: top;"&gt;
      &lt;body&gt;   
      &lt;div id="container" align="center"&gt;
          &lt;div id="title"&gt;Create Test&lt;/div&gt;
          &lt;div id="a"&gt;Input Test Name:&lt;/div&gt;&lt;div id="b"&gt;&lt;input type="text" name="testName" id="myTextBox" onkeyup="saveValue();" &gt;&lt;/div&gt;
          &lt;div id="a"&gt;Input Test Price:&lt;/div&gt;&lt;div id="b"&gt;&lt;input type="number" name="testPrice"&gt;&lt;/div&gt;
           &lt;div id="a"&gt;Select Department:&lt;/div&gt;&lt;div id="b"&gt;&lt;select name="testDept" &gt;&lt;?php echo $selectDept; ?&gt;&lt;/select&gt;&lt;/div&gt;
  
      &lt;div id="results"&gt;&lt;/div&gt;&lt;div id="a"&gt;&lt;?php echo $pagination; ?&gt;&lt;/div&gt;
  &lt;div align="right" style="padding: 10px;"&gt;&lt;input type="submit" name="save" value="Submit"&gt;&lt;/div&gt; &lt;/div&gt;
  &lt;?php
  }
  ?&gt;   
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my fetch_pages.php code. 
  this php page help me to keep the textbox values through pagination through jquery it will be loaded without going the another page of pagination</p>
  
  <pre><code>&lt;?php
  
  include("connect.php"); 
  require_once('classes/tool.php');
  $item_per_page=10;
  //sanitize post value
  $page_number = $_POST["page"];
  
  //validate page number is really numaric
  if(!is_numeric($page_number)){die('Invalid page number!');}
  
  //get current starting point of records
  $position = ($page_number * $item_per_page);
  
  //Limit our results within a specified range. 
  $results = mysqli_query($con,"SELECT * FROM tblitem ORDER BY ItemID ASC LIMIT $position, $item_per_page");
  $connection=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
  $selectMeasure='';
  $measurements = Tool::SP_Measurement_Select();    
  foreach($measurements as $measure) {      
      $selectMeasure.='&lt;option value=' . $measure['MeaName'] . '&gt;' . $measure['MeaName'] . '&lt;/option&gt;';
  $i=0;
  while($item = mysqli_fetch_array($results))
  {
      echo "&lt;div id='a'&gt;&lt;input type='checkbox' name='items[$i]' id='item[]' value='". $item['ItemID'] ."' &gt;".$item['ItemName']."&lt;/div&gt;";
      echo "&lt;div id='b'&gt;&lt;input type='number' name='quantity[$i]' class='quantity' /&gt;&lt;/div&gt;";        
      echo "&lt;div id='b'&gt;&lt;select name='measurement[$i]' class='quantity'&gt;'".$selectMeasure."'&lt;/select&gt;&lt;/div&gt;";
  $i++;
  }
  ?&gt;
  </code></pre>
  
  <p>Hope you can help me. Thanks in advance</p>