Created
August 19, 2014 08:15
-
-
Save AbhishekGhosh/d8ec5db1afdc7278b36b to your computer and use it in GitHub Desktop.
Graph From MySQL Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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