Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编辑Javascript调用MySQL_Javascript_Php_Mysql - Fatal编程技术网

编辑Javascript调用MySQL

编辑Javascript调用MySQL,javascript,php,mysql,Javascript,Php,Mysql,我有一个在提交复选框表单时触发的函数: function report_build() { var checked_count = 0; var where = "" $('.peer:checked').each(function (i) { checked_count++; var label = $(this).parent().next().html(); where += "'" + label + "', "

我有一个在提交复选框表单时触发的函数:

function report_build() {
   var checked_count = 0;
   var where = ""
   $('.peer:checked').each(function (i) {
   checked_count++;
   var label = $(this).parent().next().html();
   where +=  "'" + label + "', "   
                });
   $('#tabs-1').html(where);
   $('#ui-id-6').click();

            }
我想将where变量发送到PHP脚本,以便在select列表的where子句中使用。最简单的方法是什么


谢谢

您应该尝试使用HTML
发布或获取它。它们发送到PHP,但javascript是在客户端运行的。

我不太确定您在问什么,但如果我没有弄错的话,您希望将一个变量从javascript发送到PHP。使用ajax可以很容易地做到这一点。这里有一个例子

$.ajax(
{
    type: "POST",
    url: "your_php_name.php",
    data: { 
        'where' : where
    },
    dataType: "html",
    success: function(answer)
    {
        //fires when php finishes it job.           
    }
});
在php端,您可以使用
$\u POST['where']读取变量

您必须使用它

一个简单的帖子就可以完成这项工作:

$.post('handle-sql.php', {where: where}, function(data) {
    // In the handle-sql.php script, use $_POST['where'];
    // Callback function: called after php script is completed
    // Where 'data' is the echo'ed data from the PHP script
});

看看这些:| |这里没有php或mysql代码,这会让这个问题变得既不清楚又过于宽泛。也没有HTML来支持发布的代码。关于过去的问题以及可能给出的解决方案,您的接受记录是有问题的。我将返回并接受解决我问题的答案。我很抱歉没有做那件事。