单击表行确认行更新

时间:2017-03-08 07:45:35

标签: javascript php jquery html ajax

我有一个多行的表。 This is the Image of Row wise

点击"点击我"

我想通过AJAX确认,但是它正在努力争取第一行

下面是我的AJAX,php和响应代码

AJAX代码

<script type="text/javascript">
$(document).ready(function(){
$(".click").click(function() {
var regid = $('.click').val();

$.ajax({
method: "POST",
url: "job_confirm_employer.php",
data: "regid="+ regid ,
    success: function(html){
    $("#disp").html(html);
    }
    });

});

和显示行的html代码以及当我点击CLICK ME按钮时在第一行上工作,但是对于剩余的行则失败。

<?php
$cn=makeconnection();
  $se="select e.*, pj.*,jc.*,js.* from employer e  
  INNER JOIN post_job pj ON $empid=pj.emp_id 
  INNER JOIN job_confirm jc ON jc.job_post_id=pj.job_post_id 
  INNER JOIN job_seeker js ON jc.reg_id=js.reg_id 
   where e.emp_id=$empid";
  $result=mysqli_query($cn,$se);
  $r=mysqli_num_rows($result);
  $n=0;
  while($data=mysqli_fetch_array($result))
  {
  ?>
  <tr>
 <form action="job_confirm_employer.php" method="post">
 <td><?php echo $data["job_name"] ?></td>
 <td><?php echo $data["reg_name"] ?></td>
 <td><?php echo $data["reg_father"] ?></td>
 <td>
 <?php echo $data["reg_gen"]; echo "/"; echo  $data["reg_age"] ?></td>
  <td><?php echo $data["reg_add"] ?></td>
  <td><?php echo $data["reg_mob"] ?></td>
  <td><?php echo $data["reg_aadhar"] ?></td>
   <td><?php echo $data["reg_email"] ?></td>
    <td><img src="../job_seeker_pic/<?php echo $data["reg_pic"] ?>"/></td>
  <td><?php echo $data["job_applied_date"] ?></td>
   <td><?php 
      $status=$data["confirm"];
         if ($status=="1")
       {echo "Confirm";}
      else{echo "Not Confirm";}?></td><td>
     <button class="click" name="regid" type="submit" 
      value="<?php echo $data["job_confirm_id"] ?>">Click ME</tr>
        <?php } mysqli_close($cn); ?></tbody>

和PHP点击符合代码

<?php
{ 
$con=makeconnection();
$regid=$_POST['regid'];
$datenow=date("Y-m-d");
$sql = "UPDATE job_confirm SET confirm = 1 WHERE job_confirm_id='".$regid."' ";
    if (!mysqli_query($con,$sql))
         {
           die('Somthing Goes Wrong: ' . mysql_error());
              echo "<span style='color:red;'>Already Confirm</span>";
         }
          else{
            echo "<span style='color:red;'>Confirmed</span>";
              }
    mysqli_close($con);
   ?>

0 个答案:

没有答案