Ok, here's example PHP to get you started:

<?php
/* $server = the IP address or network name of the server
 * $userName = the user to log into the database with
 * $password = the database account password
 * $databaseName = the name of the database to pull data from
 */
$con = mysql_connect($server, $userName, $password) or die('Error 
connecting to server');
 
mysql_select_db($databaseName, $con); 

// write your SQL query here (you may use parameters from $_GET or $_POST 
if you need them)
$query = mysql_query('SELECT column1, column2, column3 FROM myTable');

$table = array();
$table['cols'] = array(
/* define your DataTable columns here
 * each column gets its own array
 * syntax of the arrays is:
 * label => column label
 * type => data type of column (string, number, date, datetime, boolean)
 */
    array('label' => 'Label of column 1', 'type' => 'string'),
array('label' => 'Label of column 2', 'type' => 'number'),
array('label' => 'Label of column 3', 'type' => 'number')
// etc...
);

$rows = array();
while($r = mysql_fetch_assoc($query)) {
    $temp = array();
// each column needs to have data inserted via the $temp array
$temp[] = array('v' => $r['column1']);
$temp[] = array('v' => $r['column2']);
$temp[] = array('v' => $r['column3']);
// etc...
 // insert the temp array into $rows
    $rows[] = array('c' => $temp);
}

// populate the table with rows of data
$table['rows'] = $rows;

// encode the table as JSON
$jsonTable = json_encode($table);

// return the JSON data
echo $jsonTable;
?>

You will have to fill in the database connection information, write your 
SQL query, define the columns in $table['cols'], and adjust the while loop 
to ensure that all columns of data get populated.  You should be able to 
navigate to that page in your browser and see a string of JSON data.  When 
you have a basic version running, I'll help you hook it up to your chart(s).

On Wednesday, December 5, 2012 10:54:01 PM UTC-5, Chrystopher Medina wrote:
>
> hi my frined thanks for answering me my question. could you be more 
> expecific u know i really dont know speak english very well. and i just 
> began to study this about how to program whit ajax .... really its posible 
> .... could u help me my friend could u give me ur email or ur facebook 
> page. or something like that. ....... its very important to me to do this. 
> i ve spend months with this work. and it doesnt work ....... please 
> explaime how i can do in order to achieve this ............
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/U1sl7j34d6oJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to