Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/10/2008, 08:36
luiito
 
Fecha de Ingreso: octubre-2008
Mensajes: 4
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: JpGraph y base de datos mysql

Voy a poner el código para q mireis si hay algun error

<?php
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");

function connect2(){

$dbhost = 'localhost' ;
$dbport = '';
$dbname = '211' ;
$dbuser = 'root' ;
$dbpasswd = '' ;

$conexion = new mysqli($dbhost,$dbuser,$dbpasswd,$dbname);
if(mysqli_connect_errno()){
echo "Error al conectar con la base de datos.";
exit;
}
return $conexion;
}

$connect = mysql_connect("$dbhost","$dbuser","$dbpasswd");

$sql = "Select * From mdl_grade_grades Where userid = '3' ";
$res = mysql_db_query("$dbname","$sql",$connect);
$records = mysql_num_rows($res);

for($i=0;$i<$records;$i++);
{
$row = mysql_fetch_row($res);
$a1[] = $row[0];

}
mysql_close($connect);

// Some data
$datay1=array_merge($a1);

// Create the basic graph
$graph = new Graph(800,250,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40,150,30,40);

// Adjust the position of the legend box
$graph->legend->Pos(0.02,0.15);

// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('[email protected]');
$graph->legend->SetFillColor('[email protected]');

// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());

// Set a nice summer (in Stockholm) image
$graph->SetBackgroundImage('logo.jpg',BGIMG_COPY);

// Set axis titles and fonts
$graph->xaxis->title->Set('Módulos');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetColor('black');

$graph->yaxis->title->Set('Notas');
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetColor('black');

$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('black');

$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('black');

//$graph->ygrid->Show(false);
$graph->ygrid->SetColor('[email protected]');

// Setup graph title
$graph->title->Set('Evaluación');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);

// Create the three var series we will combine
$bplot1 = new BarPlot($datay1);

// Setup the colors with 40% transparency (alpha channel)
$bplot1->SetFillColor('[email protected]');

// Setup legends
$bplot1->SetLegend('Alumno');

// Setup each bar with a shadow of 50% transparency
$bplot1->SetShadow('[email protected]');

$gbarplot = new GroupBarPlot(array($bplot1));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);

$graph->Stroke();
?>


Después de esto no m muestra nada, se me ve la página en blanco.
¿Alguna idea?

Gracias