我需要在Google图表脚本之前传递$ _GET [' variableID']中的变量,然后传递到目标页面PHP,以确定我想要查询哪个客户端。我怎么能? (注意:我不是javascript的天才)。非常感谢!!
这是我定义
的chart.js/* Get data from the database */
function getData() {
jQuery.ajax({
url: 'get.php',
type: 'GET',
dataType: 'json',
mimeType: 'multipart/form-data',
contentType: false,
cache: false,
processData: false,
success: function( data, jqXHR ) {
if( data == "null" ) {
// just in case
} else {
drawGraph( data );
}
},
error: function( textStatus ) {
console.log(" error. damm. ");
}
});
}
/* Initialization of Google Charts API */
google.load( "visualization" , "1", { packages: [ "corechart" ] });
google.setOnLoadCallback( getData );
/* Chart to render time-user graphs */
function drawGraph( data ) {
for( var i = data.length; i > 0; i-- ) {
data[i] = data[i - 1];
}
data[0] = [ 'Data', 'Comandes' ];
console.log( data );
var chartData = google.visualization.arrayToDataTable( data );var options = {
title: '','legend':'none','chartArea': {'width': '100%', 'height': '80%'},
backgroundColor: {
stroke: '#a5a5a5',
strokeWidth: 1
},
hAxis: {
format: 'M/d/yy',
gridlines: {count: 15}
},
vAxis: {
gridlines: {color: '#d0d0d0'},
minValue: 0
}
};
var chart = new google.visualization.LineChart( document.getElementById( 'chart_div' ) );
chart.draw( chartData , options );
}
这是get.php(特别注意 WHERE idclient = GET variableID )
include('lib/connection.php');
if($_GET) {
$query = "select DATE( data ), COUNT(*)
from smarty_pedidos **WHERE idclient=GET variableID**
group by DATE( data )";
$result = mysql_query( $query );
$rows = array();
while( $row = mysql_fetch_array( $result ) ) {
$rows[] = array( '0' => $row['0'] , '1' => $row['1'] );
}
//print json_encode($rows);
print json_encode($rows, JSON_NUMERIC_CHECK);
}
答案 0 :(得分:0)
$_GET['variableID']
然后在PHP代码中,使用$query = "select DATE( data ), COUNT(*)
from smarty_pedidos WHERE idclient=$_GET['variableID']
group by DATE( data )";
{{1}}