Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][MySQL][PHP]Google charts dane z mysql
mateoosh_tar
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 28.07.2011

Ostrzeżenie: (0%)
-----


Witam. Posiadam tabelę w mysql z danymi rozmiar i pwaga(waga procentowa).

Chciałem wstawić dane z php do skryptu html. Zrobiłem coś takiego, lecz nie działa:

  1.  
  2. <html>
  3.  
  4. <?php
  5. $db = mysql_connect('localhost', 'root', 'admin');
  6. mysql_select_db('nr_id', 'raporty','magazyn', $custombaza);
  7. //polskie kodowanie
  8. mysql_query("SET NAMES utf8");
  9. mysql_query("SET CHARACTER SET utf8");
  10. mysql_query("SET collation_connection = utf8_polish_ci");
  11.  
  12.  
  13. function zrobzmienne()
  14. {
  15. $wysz_part = mysql_query("select rozmiar,pwaga FROM raporty.37_9_6_10_1") or die('Błąd zapytania: '.mysql_error());
  16. while ($wysz = mysql_fetch_assoc($wysz_part))
  17. {
  18. $asd[''] ='[\''.$wysz['rozmiar'].'\', '.$wysz['pwaga'].'],<br/>';
  19.  
  20.  
  21. }
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. ?>
  29. <head>
  30. <!--Load the AJAX API-->
  31. <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  32. <script type="text/javascript">
  33.  
  34. // Load the Visualization API and the piechart package.
  35. google.load('visualization', '1.0', {'packages':['corechart']});
  36.  
  37. // Set a callback to run when the Google Visualization API is loaded.
  38. google.setOnLoadCallback(drawChart);
  39.  
  40. // Callback that creates and populates a data table,
  41. // instantiates the pie chart, passes in the data and
  42. // draws it.
  43. function drawChart() {
  44.  
  45. // Create the data table.
  46. var data = new google.visualization.DataTable();
  47. data.addColumn('string', 'Topping');
  48. data.addColumn('number', 'Slices');
  49. data.addRows([
  50. <?php
  51. zrobzmienne();
  52. ?>
  53. ]);
  54.  
  55. // Set chart options
  56. var options = {'title':'Procentowy wykres raportu',
  57. 'width':400,
  58. 'height':300};
  59.  
  60. // Instantiate and draw our chart, passing in some options.
  61. var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
  62. chart.draw(data, options);
  63. }
  64. </script>
  65. </head>
  66.  
  67. <body>
  68. <!--Div that will hold the pie chart-->
  69. <div id="chart_div"></div>
  70. </body>
  71. </html>
  72.  


Tutaj podaję linka do przykładu jak powinny być zapisane dane w skrypcie:
http://code.google.com/intl/pl/apis/chart/...uick_start.html

Proszę o podpowiedzi jak powinienem postąpić.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 12:34