嗨,大家好我是一個新的我有一個關於如何從輸入表格VAR到請求的URL問題MySQL的highcharts餡餅PHP獲得VAR值到請求的URL
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>中國武夷 000797 - 歷史大單</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
},
title: {
text: '中國武夷 000797 歷史大單 from 2016-03-14'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage,2) +' %';
}
},
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,0) +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'BigVolume share',
colors: ['#DD5044','#17A05D','#FFCE43'],
data: []
}]
}
$jsonurl="000797vol400piedata.php?df=";
$.getJSON($jsonurl, function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
$('#button').click(function() {
$jsonurl="000797vol400piedata.php?df=";
$.getJSON($jsonurl2, function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options).redraw();
});
});
// window.setInterval(function(){
// $.getJSON("000797datapievol400.php", function(json) {
// options.series[0].data = json;
// chart = new Highcharts.Chart(options);
// });
//}, 3000);
});
</script>
<!-- <script src="http://code.highcharts.com/highcharts.js"></script> -->
<script src="../../stock/js/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="min-width: 280px; height: 230px; margin: 0 auto"></div>
<form name="form" action="<?php $jsonurl2 = $jsonurl.$_GET['df'];?>" method="GET">
<input type="text" name="df" value="2016-4-1" />
<input type="button" id="button" value="Start Date" />
</form>
</body>
</html>
的000797vol400piedata.php代碼
<?php
$con = mysql_connect("localhost","tushare","tusharetushare");
$df = htmlspecialchars($_GET["df"]) ;
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("stockhistory", $con);
$resultx = mysql_query("select type,sum(volume) from `vol400-000797` where type='買盤' and date BETWEEN '$df' AND current_date()");
$rowsx = array();
while($r = mysql_fetch_array($resultx)) {
$row[0] = $r[0];
$row[1] = $r[1];
array_push($rowsx,$row);
}
$resulty = mysql_query("select type,sum(volume) from `vol400-000797` where type='賣盤' and date BETWEEN '$df' AND current_date()");
$rowsy = array();
while($r = mysql_fetch_array($resulty)) {
$row[0] = $r[0];
$row[1] = $r[1];
array_push($rowsy,$row);
}
$resultz = mysql_query("select type,sum(volume) from `vol400-000797` where type='中性盤' and date BETWEEN '$df' AND current_date()");
$rowsz = array();
while($r = mysql_fetch_array($resultz)) {
$row[0] = $r[0];
$row[1] = $r[1];
array_push($rowsz,$row);
}
$rows=array_merge($rowsx,$rowsy,$rowsz);
print json_encode($rows, JSON_NUMERIC_CHECK);
mysql_close($con);
?>
我覺得有什麼毛病表單代碼 的$ jsonurl2當我點擊按鈕不能獲得價值
$ jsonurl2的輸出是怎樣的?你不能像普通的js變量那樣在js中使用php變量。 –
jsonurl返回我的json fomat數據 – dev
我的問題是如何獲得輸入表單var並將該var放入$ jsonurl2 – dev