在单击表单时,转移到另一个PHP页面,并显示复选框的结果

On clicking the form divert to another PHP page with the results of the check box

本文关键字:显示 页面 复选框 结果 PHP 另一个 表单 单击 转移      更新时间:2023-09-26

我在一个页面上有一组复选框,提交按钮value="compare"不在表单中。我已经为表单外部的按钮比较编写了一个jQuery。我正在并排比较一组表格。我的代码在同一个页面上工作得很好。我不知道如何在另一个页面中显示结果。谁来帮帮我。

<?php
require('db.php');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comparision</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script type="text/javascript"> 
$(document).ready(function(){
    $("#compare_id").click( function(){
$("input:checkbox:not(:checked)").each(function() {
    var column = "table ." + $(this).attr("name");
    $(column).hide();
});
    });
});
$(document).ready(function(){
    $("#compare_id").click( function(){
$("input:checkbox:(:checked)").each(function(){
    var column = "table ." + $(this).attr("name");
    $(column).toggle();
});
    });
});

</script>
</head>
<body>
<input name="compare" id="compare_id" type="button" value="Compare"  />
<form  action="test.php"  method="post" name="printers_comparision">
  <p>
    <label>
      <input type="checkbox" name="p1" value="Printer1" id="CheckboxGroup1_0" />
      Printer1</label>
    <label>
      <input type="checkbox" name="p2" value="Printer2" id="CheckboxGroup1_1" />
      Printer2</label>
    <label>
      <input type="checkbox" name="p3" value="Printer3" id="CheckboxGroup1_2" />
      Printer3</label>
    <label>
      <input type="checkbox" name="p4" value="Pritner4" id="CheckboxGroup1_3" />
      Printer4</label>
    <label>

</form>
<table width="1023" border="1">
  <tr>
    <td width="193"></td>
    <td class="p1" width="113"><img src="images/im.png"/></td>
    <td class="p2" width="67"><img  src="images/im.png"/></td>
    <td class="p3" width="67"><img  src="images/im.png"/></td>
    <td class="p4" width="67"><img  src="images/im.png"/></td>
</tr>
<tr>
  <td>Title</td>
    <td class="p1" >Printer1</td>
    <td class="p2" >Printer2</td>
    <td class="p3" >Printer3</td>
    <td class="p4" >Printer4</td>
</tr>
<tr>
    <td>Manufacturer</td>
    <td class="p1" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="1";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p2" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="2";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p3" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="3";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p4" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="4";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
</tr>
</body>
</table>
</table>

如果需要跨页面显示数据,可以尝试使用SESSION变量或设置COOKIE