utworzyłem 2 pliki jeden php pobiera i zlicza z mysql ilość odwiedzin i nazwy podstron i przesyła do drugiego w js zmienną z otrzymanymi wynikami. i wszystko działa do momentu wykozystania tej zmiennej zamiast wykresy pojawia się biały ekran
Pierwszy plik
Kod
<?php
echo"<html>";
echo" <head>";
include ('conection.php');
$query = "SELECT nazwapodstr, COUNT(DATA) FROM stats19 GROUP BY nazwapodstr";
$result = mysql_query($query) or die(mysql_error());
// Print out result
$a= '';
while($row = mysql_fetch_array($result)){
$a.= "['".$row['nazwapodstr']."',".$row['COUNT(DATA)']."],";
//echo "<br />";
}
echo $a;
$a;
echo '<form action="wykreskolowy.php" method="GET">';
echo' <input type="hidden" name="a" value="'.$a.'" />'; //<<<<<<<<<<<<<<<<<<<
echo'<input type="submit" name="button3" value="wyslij" /></form>';
?>
echo"<html>";
echo" <head>";
include ('conection.php');
$query = "SELECT nazwapodstr, COUNT(DATA) FROM stats19 GROUP BY nazwapodstr";
$result = mysql_query($query) or die(mysql_error());
// Print out result
$a= '';
while($row = mysql_fetch_array($result)){
$a.= "['".$row['nazwapodstr']."',".$row['COUNT(DATA)']."],";
//echo "<br />";
}
echo $a;
$a;
echo '<form action="wykreskolowy.php" method="GET">';
echo' <input type="hidden" name="a" value="'.$a.'" />'; //<<<<<<<<<<<<<<<<<<<
echo'<input type="submit" name="button3" value="wyslij" /></form>';
?>
Drugi plik
Kod
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
//a = "<?= $_GET['a']; ?>";
// alert(a);
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
//data.addRows([['Mushrooms', 3],['Onions', 1],['Olives', 1],['Zucchini', 1],['Pepperoni', 2],]);
var a = "<?= $_GET['a']; ?>";
data.addRows([a]);
//data.addRows([['hobby', 3],['kontakt', 4],['NOT NULL', 44],['qwerty 2', 5],['start', 21],['ttt', 4],]);
//to powinno być w zmiennej a ['hobby', 3],['kontakt', 4],['NOT NULL', 44],['qwerty 2', 5],['start', 21],['ttt', 4],
//data.addRows(["<?= $_GET['a']; ?>"]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
//a = "<?= $_GET['a']; ?>";
// alert(a);
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
//data.addRows([['Mushrooms', 3],['Onions', 1],['Olives', 1],['Zucchini', 1],['Pepperoni', 2],]);
var a = "<?= $_GET['a']; ?>";
data.addRows([a]);
//data.addRows([['hobby', 3],['kontakt', 4],['NOT NULL', 44],['qwerty 2', 5],['start', 21],['ttt', 4],]);
//to powinno być w zmiennej a ['hobby', 3],['kontakt', 4],['NOT NULL', 44],['qwerty 2', 5],['start', 21],['ttt', 4],
//data.addRows(["<?= $_GET['a']; ?>"]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>