请,我想将这个javascript代码执行到php和mysqli查询中。如果点击== 1,那么我想执行这个javascript代码,它也有来自php使用json的价值。如果我使用< ?和? >它不是运行javascript作为查询的一部分!也使用echo''在som javacript行中不起作用
<?php
$search_Query = "SELECT * FROM mydate WHERE id='1' and click='1' ";
$search_Result = mysqli_query($conn, $search_Query);
if($search_Result)
{
if(mysqli_num_rows($search_Result))
{
while($row = mysqli_fetch_array($search_Result))
{
$mydate=$row['dateadd'];
if ($row['click']=='1'){
$json_date = json_encode($mydate);
?>
<script>
var mydate = <?php echo $json_date; ?>
$('#datepicker').change(function () {
$.post('check_data.php', {
dtpickerdate : $(this).val()
}, function (response) {
$('table').html(response);
});
});
$("#datepicker").datepicker({dateFormat: "mm-dd-yy",}).datepicker("setDate", mydate).change();
</script>
<?php
$conn->query("UPDATE `mydate` SET `click`='0'") or die('Error: ' . mysqli_error($conn));
}
else
if ($row['click']=='0'){
?>
<script>
$('#datepicker').change(function () {
$.post('check_data.php', {
dtpickerdate : $(this).val()
}, function (response) {
$('table').html(response);
});
});
$("#datepicker").datepicker({dateFormat: "mm-dd-yy",}).datepicker("setDate", new Date()).change();
</script><?php
}
}
}
}
?>