Php 在AJAX中无法将行的值传递给另一个页面

Php 在AJAX中无法将行的值传递给另一个页面,php,ajax,Php,Ajax,我有一个表,有7列ConsumpaintID、名称、学校名称等。。。还有按钮。单击按钮时,我需要将该行的complaintid传递到另一个页面。请帮我找到一个传递值的方法 <html> <body> <?php include '../library/dbconnect.php'; $query="SELECT * FROM Complaint_register WHERE status=1 ORDER BY entrydate ";

我有一个表,有7列ConsumpaintID、名称、学校名称等。。。还有按钮。单击按钮时,我需要将该行的complaintid传递到另一个页面。请帮我找到一个传递值的方法

<html>
<body>
    <?php
    include '../library/dbconnect.php';
    $query="SELECT * FROM Complaint_register WHERE status=1 ORDER BY entrydate ";
    $result=mysql_query($query) or die("Selection query of 
    Complaint_register is Error ".mysql_error());
    $num = mysql_numrows($result);
    $i=0;
    $j=1;
    ?>

    <form  action="" name="frmcomplaint" id="frmcomplaint" method="post">
    <table border="1" style="border-color: #FFFFFF;" >


     <tr>                                                                                                                       

        <th style="color: #FF0000">Sl. No</th>
        <th style="color: #FF0000">Complaint Id</th>
        <th style="color: #FF0000">Date</th>
        <th style="color: #FF0000; width:200px;" >Name Of student</th>
        <th style="color: #FF0000">District</th>
        <th style="color: #FF0000">School Name</th>
        <th style="color: #FF0000">Standard with </th>
        <th style="color: #FF0000; width:200px;">Complaint</th>

    </tr>


<?php
while($row=mysql_fetch_array($result))
{
    $date1=explode('-', $row[$i+2]);
    $entrydate=$date1[2]."-".$date1[1]."-".$date1[0];
    $job_id=$row[$i+1];
?>
    <tr>
        <td style="color: #000000"><?php echo $j;?></td>
        <td style="color: #000000"><?php echo $row[complain_Id]; ?> </td>
        <td style="color: #000000"><?php echo $entrydate;?></td>
        <td style="color: #000000" ><?php echo $row[studname];?></td>
        <td style="color: #000000"><?php echo $row[District];?></td>
        <td style="color: #000000"><?php echo $row[School_name] ;?></td>
        <td style="color: #000000"><?php 
echo    $row[Standard]."-".$row[Division];?></td>
        <td id="disp" ><?php echo $row[Complaint];?></td>
        <td id="button" name="viewbutton" >

         </td>

    </tr>

<?php

$button++;
$j=$j+1;
}


?>

</table>
</form>
</body>
</html>
而不是使用

<td id="button" name="viewbutton" >

         </td>
使用

并添加一个javascript函数

<script>
function functioname(param)
{
window.location="redirectionpage?id="+param;
}
</script>

这将重定向到id为的页面重定向页面。

当前尝试中有几个循环孔

严格使用mysqli或PDO而不是mysql,因为mysql已被弃用。 这是mysql\u num\u行,而不是mysql\u numrows。 现在来看您的问题,您可以通过使用jQueryAjax来解决这个问题

$("table").on("click","#button",function(){
  var cid = $("#disp").text(); 
  $.ajax({
         type: "GET",
         url: "anotherpage.php",
         data: { complainid: cid},
         success: function(data) {
               alert(data) //To check if response is success
               }
        });
 });
anotherpage.php:


您可以使用一个带有投诉id的链接,如complaints.php?complainid=echo您的值

    <td id="button" name="viewbutton" >
        <a href="complaints.php?complainid=<?php echo $row[complain_Id]; ?>">view complaint</a>
    </td>
如果需要的话,你可以像按钮一样设置链接的样式。
在complaints.php页面中,您可以使用您传递的id记录投诉的详细信息。

那么发布表单时有什么问题?如果你不想发布,那为什么要使用表单???
  <?php
      $cid = $_GET['complainid'];
   ?>
    <td id="button" name="viewbutton" >
        <a href="complaints.php?complainid=<?php echo $row[complain_Id]; ?>">view complaint</a>
    </td>