Skip navigation links

MySQL Forums :: PHP :: Querying Database to draw a Graph using PHPlot


Advanced Search

Querying Database to draw a Graph using PHPlot
Posted by: jeremy tan ()
Date: December 10, 2012 12:23AM

Hi i am new in php and help will be appreciated as i have encountered a certain problem.

There is a error related to the query and the script will not run. I have no idea what the error is though.

Any ideas?
<?php
//Include the code
require_once 'phplot.php';
//Define the object
$plot = new PHPlot(800,600);
//Define some data

$dbhost = "localhost";
$username="root";
$password="";
$database="roy";


mysql_connect($dbhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM try2";

$r = mysql_query($query);
if (!$r) exit();
$data = mysql_fetch_array();
$n_rows = mysql_fetch_row($r);
for ($i = 0; $i < $n_rows; $i++) $data[] = mysql_fetch_row($r, $i);


$plot->SetDataValues($data);

//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
?>

Options: ReplyQuote


Subject Written By Posted
Querying Database to draw a Graph using PHPlot jeremy tan 12/10/2012 12:23AM
Re: Querying Database to draw a Graph using PHPlot Peter Brawley 12/10/2012 11:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.