I have a script to query mysql database and display search result on split pages. Every data sets have check boxes, I want to select some data sets from my search result by clicking check boxes and to display the selected datasets when I click on display button. I want to select from many pages. not only from 1st page. can any expert give me an idea how to do this.

It is a great help if any one can help me

this is my script

<?php 

$db_host="localhost";
$db_name="test";
$db_user="root";
$db_pass="";
$per_page=10;
?>
<?php 
$connection=mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db("test",$connection);
$_REQUEST['name']=urldecode($_REQUEST['name']);
$sql="SELECT COUNT(*) as total FROM saudi_journal WHERE match (FAU, TI, 
AU, SO, PT, DP, MESH, KW, TA, AD, ISSN, NOTE) AGAINST 
('%".$_REQUEST['name']."%' in boolean mode) ORDER BY DP DESC";

$sql_result=mysql_query($sql, $connection) or die("Cannot find Server: 
".mysql_error());

$sql_result_array=mysql_fetch_array($sql_result);
$total=$sql_result_array['total'];

$sql="SELECT * FROM saudi_journal WHERE match (FAU, TI, AU, SO, PT, DP, 
MESH, KW, TA, AD, ISSN, NOTE) AGAINST ('%".$_REQUEST['name']."%' in 
boolean mode) ORDER BY DP DESC";

if (empty($_GET['result_set'])){
	$result_set=0;
	$sql.=" LIMIT $result_set, $per_page";
}
else{
	$result_set=$_GET['result_set'];
	$sql.=" LIMIT $result_set, $per_page";
}
$sql_result=mysql_db_query($db_name, $sql);
$sql_rows=mysql_num_rows($sql_result);

$cnt=0;
for ($a=0; $a<$sql_rows; $a++){
	$cnt++;
	$sql_array=mysql_fetch_array($sql_result);
	$id=$sql_array['RID'];
		$TI=$sql_array['TI'];
		$AU=$sql_array['AU'];
		$FAU=$sql_array['FAU'];
		$SO=$sql_array['SO'];
		$DP=$sql_array['DP'];
		$PT=$sql_array['PT'];
		$MESH=$sql_array['MESH'];
		$KW=$sql_array['KW'];
		$TA=$sql_array['TA'];
		$TF=$sql_array['TF'];
		$EDTA=$sql_array['EDAT'];
		$AD=$sql_array['AD'];
		$ISSN=$sql_array['ISSN'];
		$NOTE=$sql_array['NOTE'];
		$EB=$sql_array['EB'];
		$result_set++;
	

echo '<tr>'; 
						echo "<td class=\"style24\" valign=\"top\">$result_set</td>";echo"<td valign=\"top\"><input type=\"checkbox\" name=\"checkbox[$id]\" value=\"1\"><input type=\"hidden\" name=\"rid[$id]\" value=\"$id\"></td><td width=\"170\" align=\"right\" valign=\"top\"><b>Title of the Article: </b></td>";
    					echo '<td align="left" valign="top">'.$TI.'</td>';
						echo '<br>';
  					echo '</tr>';
  					echo '<tr>';
    					echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; echo '<td>&nbsp;</td><td>&nbsp;</td><td align="right"  valign="top"><b> Author(s)          : </b></td>';
    					echo '<td align="left"  valign="top">'.$AU.'</td>';
						echo '<br>';
  					echo '</tr>';
  					
  					echo '<tr>';
    					echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';echo '<td>&nbsp;</td><td>&nbsp;</td><td align="right"  valign="top"><b>Source              :</b></td>';
    					echo '<td align="left"  valign="top">'.$SO.'</td>';
						echo '<br>';
  					echo '</tr>';  					
  				
  					echo '<tr>';
    					echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';echo '<td>&nbsp;</td><td>&nbsp;</td><td align="right"  valign="top"><b>Address of the Author: </b></td>';
    					echo '<td align="left"  valign="top">'.$AD.'<hr><br></td>';
												
						  					echo '</tr>'; 									
  					
  					  					//echo '<tr>';
    					//echo '<td colspan="2" class="staffpub_left">&nbsp;</td>';
  					
					echo '</tr>';}echo'<tr><td>&nbsp;</td><td>&nbsp;</td><td><input name="display" type="submit" value="Display!"></td></tr><br><br>';
					
				echo '</table></form>';




if ($result_set<$total && $result_set>0){
	$Res1=$result_set - $per_page;
	echo "<A 
HREF=display3.php?result_set=$Res1&name=".urlencode($_REQUEST['name']).">Previous Page</A>";
}
$pages=$total / $per_page;
if ($pages>1){
	for($b=0,$c=1; $b < $pages; $b++ , $c++){
		$Res1=$per_page * $b;
		echo "<A 
HREF=display3.php?result_set=$Res1&name=".urlencode($_REQUEST['name']).">$c</A> \n";
	}
}
if ($result_set>=0 && $result_set<$total){
	$Res1=$result_set+$per_page;
	if ($Res1<$total){
		echo "<A 
HREF=display3.php?result_set=$Res1&name=".urlencode($_REQUEST['name'])."> Next Page>></A>";
	
	}
}

mysql_close($connection);

?>

Use <input type="checkbox" name="checkbox[]" value="your value" />
Keep using that for your checkboxes, but just change value="". It will put all your checkbox values into the $_REQUEST[checkbox][] array. Then on the next page and the page after, etc. etc., just output this into HTML:

<?php

$previous_checkboxes = '';
foreach ($_REQUEST['checkbox'] as $value)
{
    $previous_checkboxes .= '<input type="hidden" name="checkbox" value="' . $value . '" />';
}

?>

Use <input type="checkbox" name="checkbox[]" value="your value" />
Keep using that for your checkboxes, but just change value="". It will put all your checkbox values into the $_REQUEST[checkbox][] array. Then on the next page and the page after, etc. etc., just output this into HTML:

<?php

$previous_checkboxes = '';
foreach ($_REQUEST['checkbox'] as $value)
{
    $previous_checkboxes .= '<input type="hidden" name="checkbox" value="' . $value . '" />';
}

?>

Hi Garry

Thank you very much for your reply. I tried it but doesn't work. Can you please change it in my script and post it.

thank you in advance

This article has been dead for over six months. Start a new discussion instead.