Store multiple selection from pagination info into single array

Thread Solved
Reply

Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Store multiple selection from pagination info into single array

 
0
  #1
May 19th, 2007
Hi
I was using a schroll bar to display multiple rows of dynamically created from database records.
The scrolling was not displaying the data properly so I have decided to use pagination.
The problem I am having is,
if I select one item on page #1 and another on page #5
only the last item selected on page #5 is stored in the array.
How can I store selections from multiple pages into one array?
Noite: I am using foreach loop to insert the selected record into a seperate table.

  1. <?php
  2. session_start();
  3. include("..db_connect_in.php");
  4. ?>
  5. <html>
  6. <body>
  7. <form action ="../process.php" method="post">
  8. <php?
  9. $mysqli = db_connect();
  10. db_select($mysqli, $db_id);
  11.  
  12. /**----------------------------paging--------------------------------*/
  13. //how many rows to show per page
  14. $BottomRowsPerPage = 17;
  15. //by default we show first page
  16. $BottomPageNum = 1;
  17. //get the current page number
  18. if(isset($_GET['botpage']))
  19. {
  20. $BottomPageNum = $_GET['botpage'];
  21. }
  22. //counting the offset
  23. $BottomOffset = ($BottomPageNum - 1) * $BottomRowsPerPage;
  24.  
  25. /***************** determine which and how to select data to display ***************/
  26. $query = "SELECT c.code_id, c.code, c.description
  27. FROM code c
  28. WHERE c.fee_code = m.code
  29. AND c.section_code = 'K'
  30. ORDER BY c.fee_code";
  31.  
  32. $BottomPagingQuery = "LIMIT $BottomOffset, $BottomRowsPerPage";
  33. $result = mysqli_query($mysqli,$query.$BottomPagingQuery); //or die('Error, bot query failed');
  34.  
  35.  
  36. //search area display area layer and table
  37. echo "<table width=\"99%\" border=\"0\">
  38. <tr align=\"center\" bgcolor=\"#FFFFFF\" height=\"\">
  39. <td width=\"100%\" >
  40. <div id=\"Layer2\" style=\"position:absolute; width:100%; height:550px; z-index:2; left: 12px; top: 305px;\">
  41. <div id=\"pat-dash-scroll-box2\" style=\"overflow: off; float: left; width: 100%; height: 540px; margin: 0px; \">\n";
  42.  
  43. //table begins
  44. echo "<table width=\"99%\" height=\"332\" left =\"40\" align = \"\" border=\"0\" font face =\"arial\">\n";
  45.  
  46. /**----------------------loop record to display----------------------**/
  47. $num_service = mysqli_num_rows($result);
  48. for($i=0; $i < $num_service; $i++)
  49. {
  50. $row = mysqli_fetch_array($result);
  51. list($code_id, $fee1_code, $description) = $row;
  52.  
  53. //diaplay search results in rows
  54. echo"<tr height=\"10\">
  55. <td width=\"4%\" bgcolor=\"#fff8dc\" align=\"center\">
  56. <input type=\"checkbox\" name=\"fee1_choice[$i]\" value=\"$code_id\"></td>
  57. <td width=\"7%\" bgcolor=\"#fff8dc\" ><span class=\"style20\"><strong>$fee1_code</strong></span></td>
  58. <td width=\"3%\" bgcolor=\"$bgcolor\" height=\"10\">
  59. <input type=\"text\" name=\"fee1_unit[$i]\" size=\"1\" maxlength=\"2\" value =\"$fee1_unit\"/></td>
  60. <td width=\"79%\" bgcolor=\"$bgcolor\" class=\"style20\"> $description </td>
  61. echo"</tr>\n";
  62. }//end of for loop
  63.  
  64.  
  65. /**----------------Bottom pagination-------------------**/
  66. echo '<br>';
  67. //how many rows we have in database
  68. $result = mysqli_query($mysqli,$query) or die('Error, 2 query failed');
  69. $BottomNumRows = mysqli_num_rows($result);
  70. //how many pages we have when using paging?
  71. $BottomMaxPage = ceil($BottomNumRows/$BottomRowsPerPage);
  72. $self = $_SERVER['PHP_SELF'];
  73. /** creating 'previous' and 'next' link plus 'first page' and 'last page' link
  74. print 'previous' link only if not on page one **/
  75. if ($BottomPageNum > 1)
  76. {
  77. $BottomPage = $BottomPageNum - 1;
  78. $BottomPrev = "<a href=\"$self?u_find=$find&u_field=$field&u_search=$searching&u_back=$back&u_special=$special&u_service=$services&u_sch_yr=$schedule_year&toppage=$TopPageNum&botpage=$BottomPage\">[Prev]</a> ";
  79. $BottomFirst = "<a href=\"$self?u_find=$find&u_field=$field&u_search=$searching&u_back=$back&u_special=$special&u_service=$services&u_sch_yr=$schedule_year&toppage=$TopPageNum&botpage=1\">[First Page]</a> ";
  80. }
  81. else
  82. {
  83. $BottomPrev = '[Prev]'; // we're on page one, don't enable 'previous' link ,
  84. $BottomFirst = '[First Page]'; // nor 'first page' link
  85. }
  86. //print 'next' link only if we're not
  87. //on the last page
  88. if ($BottomPageNum < $BottomMaxPage)
  89. {
  90. $BottomPage = $BottomPageNum + 1;
  91. $BottomNext = "<a href=\"$self?u_find=$find&u_field=$field&u_search=$searching&u_back=$back&u_special=$special&u_service=$services&u_sch_yr=$schedule_year&toppage=$TopPageNum&botpage=$BottomPage\">[Next]</a>";
  92. $BottomLast = "<a href=\"$self?u_find=$find&u_field=$field&u_search=$searching&u_back=$back&u_special=$special&u_service=$services&u_sch_yr=$schedule_year&botpage=$TopPageNum&botpage=$BottomMaxPage\">[Last Page]</a>";
  93. }
  94. else
  95. {
  96. $BottomNext = '[Next]'; // we're on the last page, don't enable 'next' link
  97. $BottomLast = '[Last Page]'; // nor 'last page' link
  98. }
  99. // print the page navigation link
  100. echo"<center> ". $BottomFirst . $BottomPrev . " <strong>$BottomPageNum</strong> of <strong>$BottomMaxPage</strong> pages " . $BottomNext . $BottomLast."</center>";
  101.  
  102. echo"</div>\n";
  103. echo "</div>\n";
  104. echo "</table>\n";
  105. echo "</table>\n";
  106.  
  107. $mysqli->close();//close connection to db
  108. ?>
  109. </form>
  110. </body>
  111. </html>
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC