473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Store multiple selection from pagination info into single array

41
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.



[php]
<?php

session_start();

include("..db_connect_in.php");
?>

<html>
<body>
<form action ="../process.php" method="post">
<php?

$mysqli = db_connect();
db_select($mysqli, $db_id);


/**----------------------------paging--------------------------------*/

//how many rows to show per page
$BottomRowsPerPage = 17;

//by default we show first page
$BottomPageNum = 1;
//get the current page number
if(isset($_GET['botpage']))
{
$BottomPageNum = $_GET['botpage'];
}
//counting the offset
$BottomOffset = ($BottomPageNum - 1) * $BottomRowsPerPage;


/***************** determine which and how to select data to display ***************/
$query = "SELECT c.code_id, c.code, c.description
FROM code c
WHERE c.fee_code = m.code
AND c.section_code = 'K'
ORDER BY c.fee_code";

$BottomPagingQuery = "LIMIT $BottomOffset, $BottomRowsPerPage";
$result = mysqli_query($mysqli,$query.$BottomPagingQuery); //or die('Error, bot query failed');




//search area display area layer and table
echo "<table width=\"99%\" border=\"0\">
<tr align=\"center\" bgcolor=\"#FFFFFF\" height=\"\">
<td width=\"100%\" >
<div id=\"Layer2\" style=\"position:absolute; width:100%; height:550px; z-index:2; left: 12px; top: 305px;\">
<div id=\"pat-dash-scroll-box2\" style=\"overflow: off; float: left; width: 100%; height: 540px; margin: 0px; \">\n";


//table begins
echo "<table width=\"99%\" height=\"332\" left =\"40\" align = \"\" border=\"0\" font face =\"arial\">\n";


/**----------------------loop record to display----------------------**/

$num_service = mysqli_num_rows($result);
for($i=0; $i < $num_service; $i++)
{
$row = mysqli_fetch_array($result);

list($code_id, $fee1_code, $description) = $row;



//diaplay search results in rows
echo"<tr height=\"10\">
<td width=\"4%\" bgcolor=\"#fff8dc\" align=\"center\">
<input type=\"checkbox\" name=\"fee1_choice[$i]\" value=\"$code_id\"></td>
<td width=\"7%\" bgcolor=\"#fff8dc\" ><span class=\"style20\"><strong>$fee1_code</strong></span></td>
<td width=\"3%\" bgcolor=\"$bgcolor\" height=\"10\">
<input type=\"text\" name=\"fee1_unit[$i]\" size=\"1\" maxlength=\"2\" value =\"$fee1_unit\"/></td>
<td width=\"79%\" bgcolor=\"$bgcolor\" class=\"style20\"> $description </td>
echo"</tr>\n";

}//end of for loop




/**----------------Bottom pagination-------------------**/
echo '<br>';
//how many rows we have in database
$result = mysqli_query($mysqli,$query) or die('Error, 2 query failed');
$BottomNumRows = mysqli_num_rows($result);

//how many pages we have when using paging?
$BottomMaxPage = ceil($BottomNumRows/$BottomRowsPerPage);

$self = $_SERVER['PHP_SELF'];

/** creating 'previous' and 'next' link plus 'first page' and 'last page' link
print 'previous' link only if not on page one **/

if ($BottomPageNum > 1)
{
$BottomPage = $BottomPageNum - 1;
$BottomPrev = "<a href=\"$self?u_find=$find&u_field=$field&u_search= $searching&u_back=$back&u_special=$special&u_servi ce=$services&u_sch_yr=$schedule_year&toppage=$TopP ageNum&botpage=$BottomPage\">[Prev]</a> ";
$BottomFirst = "<a href=\"$self?u_find=$find&u_field=$field&u_search= $searching&u_back=$back&u_special=$special&u_servi ce=$services&u_sch_yr=$schedule_year&toppage=$TopP ageNum&botpage=1\">[First Page]</a> ";
}
else
{
$BottomPrev = '[Prev]'; // we're on page one, don't enable 'previous' link ,
$BottomFirst = '[First Page]'; // nor 'first page' link
}

//print 'next' link only if we're not
//on the last page
if ($BottomPageNum < $BottomMaxPage)
{
$BottomPage = $BottomPageNum + 1;
$BottomNext = "<a href=\"$self?u_find=$find&u_field=$field&u_search= $searching&u_back=$back&u_special=$special&u_servi ce=$services&u_sch_yr=$schedule_year&toppage=$TopP ageNum&botpage=$BottomPage\">[Next]</a>";
$BottomLast = "<a href=\"$self?u_find=$find&u_field=$field&u_search= $searching&u_back=$back&u_special=$special&u_servi ce=$services&u_sch_yr=$schedule_year&botpage=$TopP ageNum&botpage=$BottomMaxPage\">[Last Page]</a>";
}
else
{
$BottomNext = '[Next]'; // we're on the last page, don't enable 'next' link
$BottomLast = '[Last Page]'; // nor 'last page' link
}

// print the page navigation link
echo"<center> ". $BottomFirst . $BottomPrev . " <strong>$BottomPageNum</strong> of <strong>$BottomMaxPage</strong> pages " . $BottomNext . $BottomLast."</center>";


echo"</div>\n";
echo "</div>\n";
echo "</table>\n";
echo "</table>\n";



$mysqli->close();//close connection to db

?>
</form>
</body>
</html>

[/php]
May 19 '07 #1
1 3346
pbmods
5,821 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1.   <td width=\"79%\" bgcolor=\"$bgcolor\" class=\"style20\"> $description </td>
  2.                        echo"</tr>\n";
You're missing a '"' character here; is this intentional? Also, you'll probably like string heredoc syntax.

As for your issue, I would imagine that if your Users' selections aren't getting saved, the problem would be in ../process.php instead.

Let's have a look at that file (try to post only the relevant areas, though. Thanks!).
May 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
4
by: Christopher Brandsdal | last post by:
Hi! I have a delicatg problem.... I have made a registration form for adding my friends information in a database. The problem is that I want to connect the persons with companies in the same...
3
by: Disco-181 | last post by:
Hi, I have a script which isn't working in Mozilla based browser for some reason. I'm trying to run two functions from the body onload tag and it simply isn't happening. I have a cascading...
1
by: jeffgeorge | last post by:
Trying to create multiple acct reports based on the selection in a list box. I've set the list box for multiple selections, and in the report data source, I have a SQL statement which is reading...
2
by: Dolorous Edd | last post by:
Hi, for a program I'm working on I need to be able to drag multiple files between Windows Explorer and a ListBox, in both directions. Implementing the "drag in" was pretty easy, but I can't find...
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
4
by: serge | last post by:
I was working on figuring out where a certain application was storing the multiple selection choices I was doing through the app. I finally figured out that they were being store in an IMAGE data...
4
by: comp.lang.php | last post by:
'll try to explain this as clearly as possible, sorry if it's unclear. You have in your directory /foo 42 images You have in your database metadata for 30 out of those 42 images You have to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.