来自另一个查询的查询ajax选择输入

时间:2019-06-26 12:32:13

标签: php jquery ajax

我有一个功课来建立电影座位重定位的情况,当我选择电影X向他查询时,选择的那部电影上的每个可用日期,然后当我选择日期显示一些椅子时,这是我的代码:

 <form action="" method="POST">
            <div class="form-group">
              <label for="input-1">Film</label>
              <select class="form-control film" name="film"  id="basic-select">
                <?php 
                $idsc=$row['id_scaun_movie']; 
                 $sqls=mysqli_query($conn,"SELECT * FROM movie WHERE id='$idsc'");
                 $rows=mysqli_fetch_array($sqls);
               ?>
                <option selected value="<?=$rows['id'];?>"><?=$rows['nume'];?></option>
              <?php 

                $q = "SELECT * FROM movie";
                $qq = mysqli_query($conn, $q);
                while ($r = mysqli_fetch_assoc($qq)) {?>
                  <option value="<?=$r['id']?>"><?=$r['nume'];?></option>
                <?php }?>
            </select>
           </div>
           <div class="form-controler show_data">

          </div>
          <div class="form-controler show_data2">

          </div>
           <div class="form-group">
             <button type="submit" name="submit" class="btn btn-success">Salveaza</button>
           </div>

   </form>

这是jquery:

  <script> 
$(document).ready(function(){
  $('.film').change(function(){  
         var film_id = $(this).val();
         if(film_id == ""){
          $('.show_data').hide();
         }  
         $.ajax({  
              url:"load_data.php",  
              method:"POST",  
              data:{film_id:film_id},  
              success:function(data){  
                   $('.show_data').html(data);   
              }  
         });  
    });
});
</script>

<script> 
$(document).ready(function(){
  $('.normal_film').change(function(){  
         var scaun_id = $(this).val();
         if(scaun_id == ""){
          $('.show_data2').hide();
         }  
         $.ajax({  
              url:"load_data2.php",  
              method:"POST",  
              data:{scaun_id:scaun_id},  
              success:function(data){   
                   $('.show_data2').html(data);   
              }  
         });  
    });
});
</script>

加载电影日期:

<?php  
 include "includes/db.php"; 
 $output = '';  
 if(isset($_POST["film_id"]))  
  {  
  $id =$_POST["film_id"];
  $sql = "SELECT * FROM data_film WHERE id_film='$id'";  

  $result = mysqli_query($conn, $sql); 
  $output .= ' <select class="form-control normal_film data_s" name="date_film"  id="basic-selecte">'; 
  while($row = mysqli_fetch_array($result)) {  
      $output .= '<option value='.$row["id"].'>'.$row['data_f'].'</option>';
  }  
  $output .= '</select>';
  echo $output;  
 }  
 ?>  

然后这是在选择日期获取数据并显示我的席位的问题:

<?php  
  include "includes/db.php"; 
  $output = '';  
  if(isset($_POST["scaun_id"]))  
 {  
  $id =$_POST["scaun_id"];
  $sql = "SELECT * FROM scaune WHERE scaun_data='$id'";  

  $result = mysqli_query($conn, $sql); 
  while($row = mysqli_fetch_array($result)) {  
      $output .= '<input type="text" name="scaun" value='.$row['scaun'].'">';
  }  
  echo $output;  
  }   
  ?>  

所以基本上像这样工作:选择电影->加载日期并显示它们->从日期中选择并显示我的座位。

编辑:我尝试了这一点,但仍然没有得到任何东西

$('.normal_film').change(function(){  
        alert($(this).val());  
});

0 个答案:

没有答案