您好,我想在MySQL查询与特定ID匹配时添加一些JQuery代码,这是我的代码:
<?php
$chkgreenmark ="select * from TABLE where PARAM = '$VARIABLE'";
$sqlchkgreenmark = mysqli_query($GLOBALS['mysqli'],$chkgreenmark);
$numsqlchkgreenmark = mysqli_num_rows($sqlchkgreenmark);
if($numsqlchkgreenmark > 0) { ?>
<script type="text/javascript">
$(".calendercolumn .dragbox #dragID").append("<div class='detailssaved'><a href='#' ><img src='./images/check_mark.JPG' height='15' width='15'></a></div>");
</script>
<?php
}?>
问题是,即使我没有任何结果,我也会得到JQuery代码。
任何人都可以帮助我吗?
答案 0 :(得分:3)
试试这个
<?php
$chkgreenmark ="select * from TABLE where PARAM = '$VARIABLE'";
$sqlchkgreenmark = mysqli_query($GLOBALS['mysqli'],$chkgreenmark);
$numsqlchkgreenmark = mysqli_num_rows($sqlchkgreenmark);
if($numsqlchkgreenmark > 0)
{
echo '<script type="text/javascript">
$(".calendercolumn .dragbox #dragID").append("<div class=\'detailssaved\'><a href=\'#\' ><img src=\'./images/check_mark.JPG\' height=\'15\' width=\'15\'></a></div>");
</script>';
}
?>
答案 1 :(得分:0)
我尝试了@rynhe的答案,但在我添加文档就绪功能
之前,我没有为我工作<?php
$chkgreenmark ="select * from TABLE where PARAM = '$VARIABLE'";
$sqlchkgreenmark = mysqli_query($GLOBALS['mysqli'],$chkgreenmark);
$numsqlchkgreenmark = mysqli_num_rows($sqlchkgreenmark);
if($numsqlchkgreenmark > 0)
{
echo '<script type="text/javascript">
$(document).ready(function(e) {
$(".calendercolumn .dragbox #dragID").append("<div class=\'detailssaved\'><a href=\'#\' ><img src=\'./images/check_mark.JPG\' height=\'15\' width=\'15\'></a></div>");
});
</script>';
}
?>
答案 2 :(得分:-1)
<script type="text/javascript">
$(".calendercolumn .dragbox <?php echo $id;?>").append("<div class='detailssaved'><a href='#' ><img src='./images/check_mark.JPG' height='15' width='15'></a></div>");
</script>