944,162 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 15707
  • PHP RSS
Jul 23rd, 2006
0

passing checkbox value to next page

Expand Post »
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]<?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);

?>[/PHP]
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vipula is offline Offline
15 posts
since Apr 2005
Jul 23rd, 2006
0

Re: passing checkbox value to next page

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]<?php

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

?>[/php]
Team Colleague
Reputation Points: 53
Solved Threads: 5
PHP/vBulletin Guru
Gary King is offline Offline
360 posts
since Nov 2003
Jul 24th, 2006
0

Re: passing checkbox value to next page

Quote originally posted by Gary King ...
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]<?php

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

?>[/php]

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vipula is offline Offline
15 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: C code into php
Next Thread in PHP Forum Timeline: Fck editer need help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC