我有这个代码,我想将下面的java脚本实现到这个PHP代码中,我需要执行javascript甚至这个从index.php调用的php 任何帮助,请
<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;'> </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;'>".
}
答案 0 :(得分:1)
只需像在html中那样在php外添加脚本。 对于Ex。在你的代码中放置这样的东西。 这可能会有所帮助......
<script type = "text/javascript">
$('.estudent_id').click(function(){
$student_id = $(this).attr('name');
$('#edit_query').load('load_edit1.php?student_id=' + $student_id);
});
</script>
<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;'> </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;'>".
}
答案 1 :(得分:0)
在PHP文件中的正确位置回应javascript应该有效:
<?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>"; ?>
如果你想在多个文件中使用这个javascript,你可以将上面的内容保存为PHP文件,例如myscript.php,然后将它包含在你希望代码出现并运行的每个文件中:
<?php include('myscript.php'); ?>
答案 2 :(得分:0)
您可以回复JS:
<?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>"; ?>