用于在数据库中保存id值的AJAX代码

时间:2016-01-12 14:29:03

标签: javascript php mysql ajax

enter image description here

我想将此值doctoridclickedRightNow传递给t_appointmentdetails表。我在How to Pass variable from JavaScript to PHP Page using XMLHTTP上建议使用AJAX和JS对以前的代码进行了一些更改。预约详细信息将被插入到DB中,我也希望保存相应医生的医生。因此,通过以下更改,我可以看到在mozilla中使用inspect元素时显示的正确值。请建议我如何将其传递给DB。提前谢谢。

    import * as d3 from 'd3';
AssignDoctorIdClicked函数的

脚本:

      $sql = "SELECT doctorid, FIRST_NAME,LAST_NAME, Address, Qualification, Specialization, Consultation_Fee, Experience,image_path 
              from t_doctorprofile";
       $results = mysqli_query($db,$sql)
       or die('MySQL Error');

      echo '<h3 style="color:#674172;margin- left:120px;float:center;display:inline-block"><strong>Available Dentists</strong></h3>';
      while($result = mysqli_fetch_assoc($results)){
      echo '<div class= "fetch" style="margin-left:120px">';
      echo "<img src = 'uploads/".$result['image_path']."' width='150'  height='150'>";
      echo "<div id='info'>";
       echo "<p><strong>".$result['FIRST_NAME']." ".$result['LAST_NAME']."</strong></p></div>";
       echo "<p>".$result['Qualification']."</p>";
       echo "<p>".$result['Specialization']."</p>";
       echo "<p>".$result['Address']."</p>";
       echo "<p>"."<b>Consultation Fee-</b>"." ".$result['Consultation_Fee']."</p>";
       echo "<p>"."<b>Experience-</b>"." ".$result['Experience']."years"." </p>";   
       echo "<button class='btn btn-success btn-lg' id='$result[doctorid]' data-toggle='modal' data-target='#myModal' onclick='AssignDoctorIdClicked(id)'>
    Appointment</button>";
       echo "<script>var doctoridclickedRightNow;</script>"; 
       echo "</div>";
       echo '<form action="appointment_insert.php" method="POST">';
       echo "<div class='modal fade' id='myModal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
       echo "<div class='modal-dialog'>";
       echo "<div class='modal-content' style='background-color:#F1A9A0'>";
       echo "<div class='modal-header'>";
       echo "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>";
       echo "<h4 class='modal-title' id='myModalLabel' style='text-align:center; color:#fff'>
      <strong>Book Appointment</strong></h4><br>"; 

   echo "</div><br><br>";
   echo "<div class='modal-body'>";

appointment_insert.php页面

   <script>

     function AssignDoctorIdClicked(id) {
     console.log(id);
     var doctoridclickedRightNow = id;
     console.log(doctoridclickedRightNow);

    </script>

0 个答案:

没有答案