What is it you would like to accomplish here?  As is, that setup would work 
if you put the PHP into a file with the name "goo2.php" (or into a 
different file and changed "goo2.php" in the HTML to the name of the other 
file).  

On Monday, April 15, 2013 8:19:09 AM UTC-4, elizerbertling wrote:
>
> hi, i'm a student and new to this.. 
> i don't know how to mix html and php into one php file...anyone can help?
>
> <html>
>   <head>
>    <meta charset="utf-8">
>     <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>      <script type="text/javascript" src="
> http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";></script>
>     <script type="text/javascript">
>       google.load("visualization", "1", {packages:["corechart"]});
>       google.setOnLoadCallback(drawChart);
>  
>       function drawChart() {
>    var jsonData =$.ajax({
>           url: "goo2.php",
>           dataType:"json",
>           async: false
>           }).responseText;
>       
>         var data = new 
> google.visualization.DataTable(JSON.parse(jsonData));
> var options = {'title':'UNI STPD',
>                        'width':400,
>                        'height':300};
>
> var chart = new 
> google.visualization.ColumnChart(document.getElementById('chart_div'));
>         chart.draw(data,options);
>       }
>     </script>
>   </head>
>   <body>
>     <div id="chart_div" ></div>
>   </body>
> </html>
>
> <?php
> $host ="localhost";
> $username ="root";
> $password = "";
> $db_name = "stpd";
> $tbl_name = "users";
>
> $con=mysql_connect($host,$username,$password) or die("can't connect");
>  
> mysql_select_db("UNI", $con); 
>
> $sth = mysql_query("SELECT * FROM STPD");
> $rows = array();
> $flag = true;
>
> $table = array();
>
> $table['cols'] = array(
>
>     array('label' => 'department', 'type' => 'string'),
> array('label' => 'number_worker', 'type' => 'number'),
> );
>
> $rows = array();
> while($r = mysql_fetch_assoc($sth)) {
>     $temp = array();
>
> $temp[] = array('v' => (string) $r['department']); 
> $temp[] = array('v' => (int) $r['number_worker']); 
>
>     $rows[] = array('c' => $temp);
> }
> $table['rows'] = $rows;
> $jsonTable = json_encode($table);
> echo $jsonTable;
> ?>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to