Tutorials - Database - Page 2

Now that we have some data from the database to play with, we need to include the charting .php files:

gallery/tutorial-db-2-1.php
<?php

include_once 'php-ofc-library/open-flash-chart.php';
include_once 
'includes/db.php';

/*
 
 My connection details are hidden in the above file. You should
 uncomment the following and add your user name and password:
 
$con = mysql_connect('localhost', 'user', 'password');
$db = mysql_select_db('my_database_name', $con);
*/
$result mysql_query("select * from ofc_sourceforge_downloads order by date"$con);

if (!
$result) {
    die(
'Invalid query: ' mysql_error());
}

$data = array();
$max 0;
while(
$row mysql_fetch_array($result))
{
  
$data[] = $row['downloads'];
}

print 
'<pre>';
print_r$data );
print 
'</pre>';
To see the data produced : gallery/tutorial-db-2-1.php, then 'view source'.

Test these changes by refreshing your page ( http://example.com/ofc-chart.php )

Invalid query: No database selected