gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 23:09:46 24 4
gpt4 key购买 nike

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

Analytics.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);
});

});

HTML 代码:

 <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);

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

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

如上所示,如果我直接以 Ronnie 的身份输入值,则其工作。实际上问题是什么?请帮忙。

最佳答案

您可以使用操作

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

第二种情况:

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

关于php - 发布的值没有进入 json highcharts-php 和 mysql 的 where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18890194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com