发布的价值没有进入json highcharts-php和mysql的where子句


Posted value is not getting in the where clause with json highcharts-php and mysql

>我有两个文件1. 分析.php2. 数据.php

分析.php代码

$(document).ready(function() {
        var options = {
            chart: {
                renderTo: 'container',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            /*tooltip: {
                formatter: function() {
                    return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';
                }
            },*/
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 1) +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'Documents',
                data: []
            }]
        }

        $.getJSON("data.php",  function(json) {
            options.series[0].data = json;
            chart = new Highcharts.Chart(options);
        });
    });   

网页代码:

 <form method="post" name="havoc" >
     Search <input type="text" placeholder="Eg: Ronnie" name="authname_sa" value="">
    <input type="submit" name="search_authanalysis_sa" value="Search">
 </form>
   <?php
       if(isset($_POST['search_authanalysis_sa'])){
         $auth_sa =  mysql_real_escape_string($_POST['authname_sa']);
       }
   ?>

2. data.php Code
     <?php
       include 'connect.php';
       $df = $_POST['authname_sa'];
    $result = mysql_query("SELECT subj_area, documents, auth_name FROM subj_area WHERE  auth_name='$df'");
    $rows = array();
    while($r = mysql_fetch_array($result)) {
       $row[0] = $r[0];
       $row[1] = $r[1];
       array_push($rows,$row);
    }
       print json_encode($rows, JSON_NUMERIC_CHECK);

这里的图表工作正常。但问题出在数据.php文件中,php 变量$df具有一些由表单发布的值。但是当我尝试使用它时,它是子句没有获得该值的地方。

但是如果手动输入值,例如$result = mysql_query("从subj_area中选择subj_area、文档auth_name,其中 auth_name='Ronnie'");

如上所示,如果我直接输入值作为 Ronnie,那么它就可以工作了。问题到底出在哪里?请帮忙。

你能用到动作

<form method="post" name="havoc" action="data.php" >

第二种情况:

WHERE auth_name='".$df."'"