Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Graph From MySQL Data
<?php
$link = mysql_connect( 'database_host', 'database_user', 'database_password' );
if ( !$link ) {
die( 'Could not connect: ' . mysql_error() );
}
$db = mysql_select_db( 'test', $link );
if ( !$db ) {
die ( 'Error selecting database \'test\' : ' . mysql_error() );
}
$query = "
SELECT *
FROM test_chart_data
ORDER BY category ASC";
$result = mysql_query( $query );
if ( !$result ) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die( $message );
}
while ( $row = mysql_fetch_assoc( $result ) ) {
echo $row['category'] . ' | ' . $row['value1'] . ' | ' .$row['value2'] . "\n";
}
mysql_close($link);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.