运行mysqli命令onclick的html href链接


html href link that runs mysqli command onclick

我在一个表中有一个链接,链接到一个小工具提示。

<th><a href="#" class="tooltip">Reg NSB$

这很好,但我希望链接在点击时按该列调用表(我看到的web表中的一个常见功能…)我最初的想法是在那里放一个onclick事件,就像这样:

<th><a href="#" class="tooltip" onclick="<?php mysqli_query($con, "SELECT * FROM report WHERE PMName = '$PMSelection' AND REGNSB <> 0.000 ORDER BY RegNSB DESC Limit $LimitStart,$LimitItems"); ?>">Reg NSB$

我环顾四周,但当我点击一个"链接"时,我想不出一种方法来完成mysqli查询的运行。

谢谢!

您可以尝试以下操作:一旦用户点击该表头,就使用jQuery向web服务器发送AJAX请求:

$(".tooltip").click({function(){
    $.ajax({
            type: "POST",
            url: "server/database.php",  //Set the correct path to the php-file residing on the server here
            data: {
                //Set any data you need to send to the server here
            },
            success : function(data){
                //Called when server responded with success-code
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                //Called when server responded with error-code
            }
        })
    });

不要忘记将这些代码包装在jQuery的document.ready()-处理程序中。看看http://api.jquery.com/jquery.ajax/有关异步调用的更多信息,