Thank you for the replies. The data that is being lost is the data the user would submit to retrieve records from the database.
The source of the code can be found at the following link. The developer's email in the code is no longer valid.
http://www.planet-source-code.com/vb...d=787&lngWId=8
Global variables are set to "on" at the server.
I tried using serialize and unserialize with no effect.
See working sample page at the link below of php code that works properly when a variable is assigned a value within the php script and then passed on to the query string. Only 14 items should show up as they do in this example as containing the letter and number combination in Subtopics equal to 4a. The query string is set to only retrieve records from the MySql database where Subtopics contains “4a” without the quotes. If you click on page 2 you only see 4 records. This page works properly.
http://www.findthepower.com/M2.php
At the link below you will see how the php code does not work properly when a variable is a assigned a value by having the value passed to the query string from a url. The same issue occurs whether one uses input boxes or drop down boxes either in a separate form calling the php page or whether the input boxes or drop down boxes are on the same php page as the code. The same issue occurs whether you use POST or whether you pick up the search variable from a url.
See example page at the link below of a php results page where the code DOES NOT work properly. Click on page 2 and see more items show up than should show up. Only 14 items should show up as containing the letter and number combination in Subtopics equal to 4a. On page one there are 10 items showing. However, instead of 4 items showing on page 2 you see more than four. When you click on page two then you see page three appear at the top of page two which should not be happening. The query string is set to only retrieve records from the MySql database where Subtopics contains “4a” without the quotes. An echo statement shows that the values for the query are held for the page one cycle but the query values are deleted for the page 2 and higher pages. Thus, with the query values deleted for the page 2 and higher pages, the query pulls up all records from the database instead of just the records desired in the SeeAlso request from the url.
http://www.findthepower.com/M1.php?SeeAlso=4a
Here is the code I am using for the above (MI.php) that is not working properly.
PHP Code:
$input="$SeeAlso";
$inputnew = $input;
$query = "SELECT * FROM `View2` WHERE `Subtopic` LIKE '%$inputnew%'";
$result = mysql_query($query) or die("ERROR");
$num_record = mysql_num_rows($result);
if($num_record > $display) { // Only show 1,2,3,etc. when there are more records found that fit on 1 page
// when the page is loaded first...
if(empty($pagenr)) {
$pagenr = 1;
}
// some variables
$display = 10; // number of records to display per page
$max_pages_to_print = 7; // number of pages to show, if you change this you also have to change the variable 'middlenumber', for example:increase this one with two, increase middlenumber with one
$startrecord = $pagenr * $display; // first record to show from the queryresult
$num_pages = intval($num_record / $display) + 1; // total number of pages
$loopcounter = 0; // counter for whileloop
$currentpage = $pagenr; // Page where we are at the moment
$middlenumber = 3; // Number will be decreased from variable currentpage in order to get the currentpage always in the middle
$colourcounter = 0; // Variable to change the background-color of the <td>
$i = 1; // variable that will print 1,2,3,etc..
$x = 0; // variable i use to put always the current, marked page in the middle
// actual stuff starts here
print("<table border=0 align=center><tr>");
if($currentpage >= $max_pages_to_print) {
print("<td><a href=\"$PHP_SELF?pagenr=1\">First</a>...</td>");
}
//BEGIN LOOP
while($loopcounter < $max_pages_to_print) {
if($currentpage >= $max_pages_to_print) { // If user clicks om page higher than $max_pages_to_print
// Mark current page
if($currentpage == $i) {
print("<td>$i  </td>"); // print pagenumbers
$i += 1; //increase pagenr
$loopcounter += 1; // increase loopcounter
}
// End marking
if($i > $num_pages) { // if last page has been printed, exit loop
break;
}
if($x == 0) {
$i = $currentpage - $middlenumber; // current page will always be printed in the middle
}
print("<td><a href=\"$PHP_SELF?pagenr=$i\">$i</a>  </td>"); // print pagenumbers
$x = $x + 1;
$i += 1; //increase pagenr
$loopcounter += 1; // increase loopcounter
}
else { // Else user clicks on a pagenumber lower $max_pages_to_print
// Mark current page
if($currentpage == $i) {
print("<td>$i  </td>"); // print pagenumbers
$i += 1; //increase pagenr
$loopcounter += 1; // increase loopcounter
}
// End marking
if($i > $num_pages) { // if less than $max_mages_to_print, exit loop
break;
}
print("<td><a href=\"$PHP_SELF?pagenr=$i\">$i</a>  </td>"); // print pagenumbers
$i += 1; //increase pagenr
$loopcounter += 1; // increase loopcounter
} // End if
}
// END LOOP
if(($num_pages > $max_pages_to_print AND // notice the user that there are more pages
$i <= $num_pages)) {
print("<td>...<a href=\"$PHP_SELF?pagenr=$num_pages\">Last</a></td>");
}
print("</tr></table>");
$startrecord = $startrecord - $display; // Set startrecord to the right position
// Some calculation for the lastrecord
if($currentpage == $num_pages) { // Last page...
$lastrecord = $num_record; // so $lastrecord = $num_record
}
else {
$lastrecord = ($currentpage * $display);
}
} // End of the first if-statement
// Some info
print("<table align=center>
<tr><td>You are now on page $currentpage</td></tr>
<tr><td>There are $num_pages pages in total</td></tr>
<tr><td>$num_record records are spread over $num_pages pages</td></tr>
<tr><td>Current display : $startrecord - $lastrecord</td></tr>
</table>");
// End info
// actual query, watch the end($startrecord, $display)
$query2 = "SELECT * FROM `View2` WHERE `Subtopic` LIKE '%$inputnew%' LIMIT $startrecord, $display";
$result2 = mysql_query($query2) or die("ERROR");
// print results on screen
print("<table border=0 align=center width=300 bgcolor=#0E711D cellpadding=\"2\" cellspacing=\"1\"><tr><td><font color=#FFFFFF><b>Topic</b></font></td><td align=right><font color=#FFFFFF><b>Subtopic</b></font></td></tr>");
$Field1="Topic";
$Field2="Subtopic";
//Use only $Field references in the statements below
while(list($Field1, $Field2) = mysql_fetch_row($result2)) {
if ($colorcounter == 0) {
$colorbg = "#ECE28B";
}
else {
$colorbg = "#F4EFC1";
$colorcounter = $colorcounter - 2;
}
print("<tr><td bgcolor=$colorbg>$Field1</td><td align=right bgcolor=$colorbg>$Field2</td></tr>");
$colorcounter = $colorcounter + 1;
}
print("</table>");
echo "See Also At Bottom of Code";
echo $SeeAlso
?>
Thank you again for the replies.