dqhnp44220 2017-01-29 19:07
浏览 33

如何将javascript实现到php文件中

I have this code and i want to implement the java script below into this php code, I need to excute javascript even this php called from index.php any help please

<script type = "text/javascript">

        $('.estudent_id').click(function(){
            $student_id = $(this).attr('name');
            $('#edit_query').load('load_edit1.php?student_id=' + $student_id);
        });
    });
</script>

Check_data.php

<table id = "table" class = "table table-bordered">

<?php
$dtpickerdate = isset($_POST['dtpickerdate']) ? $_POST['dtpickerdate'] : NULL;

 $q_customer = $conn->query
                             ("SELECT * from orders inner JOIN customer_order on customer_order.order_no =orders.order_no and orders.date like'$dtpickerdate' inner join driver_order  on driver_order.order_no=orders.order_no LEFT JOIN customer on customer.phone=customer_order.phone order by k_time,time desc" )
 or die(mysqli_error());

 $k_time = '';
 while($f_customer = $q_customer->fetch_array()){
 $s=mysqli_num_rows($q_customer);
 ?>
  <tr>
 <?php   

    if($k_time == '' || $k_time != $f_customer['k_time']){
     $k_time = $f_customer['k_time'];
     echo '<td align="center" > <span style=" font-weight:bold;">' 
     .$f_customer['k_time']. '</td>';
      } else{
      echo "<td td style=' border: none;'>&nbsp;</td>";
      }
       echo "<td style='background-color: #5f5d5d; ' align='center'  span style='font-weight:bold;'> <a   href = '#' style='color:#ececec;font-weight:bold;' data-toggle = 'modal' data-target = '#action'>".$f_customer['order_no']."</a></td>";

   echo    "<td style='background-color: #5f5d5d;color:#ececec;'>" .$f_customer['first_name']."</td>"; 
  echo "<td style='background-color: #5f5d5d;color:#ececec;'>". 
}
  • 写回答

3条回答 默认 最新

  • dougekui1518 2017-01-29 19:22
    关注

    Echoing the javascript at the right place in your PHP file(s) should work:

    <?php echo "<script type = 'text/javascript'>$('.estudent_id').click(function(){$student_id = $(this).attr('name');$('#edit_query').load('load_edit1.php?student_id=' + $student_id);});</script>"; ?>
    

    If you want this javascript in multiple files, you could save the contents above as a PHP file, for example myscript.php and then include it in every file where you want the code to appear and run using this:

    <?php include('myscript.php'); ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大