|
Posted by Mushroom_bobble on 11/11/05 16:41
How do I pass data to a graph so that it doesn't give me an error?
Code:
<?php
$id = $_GET["id"]; //this comes from another page -- a link is pressed
etc...
$db = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error()); exit();
}
//echo $id;
$result = mysqli_query($db, "SELECT ID, treatConc, areaVN FROM Cells
WHERE ID='$id'");
$row = mysqli_fetch_array($result);
//echo $row["areaVN"];
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
//$datay = array(1.23,1.9,1.6,3.1,3.4,2.8, 5, 4);
$datay = split("\t", $row["areaVN"]); // i use split because the data
doesnt actualy have comma's between each number
$graph = new Graph(800,300,"auto");
$graph->SetScale("linlin");
$graph->img->SetMargin(50,40,40,50);
$graph->SetShadow();
$graph->title->Set("Cell Area over Time");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->Set("Time");
$graph->yaxis->title->Set("Area");
$p1 = new LinePlot($datay);
$p1->SetFillColor("orange");
//$p1->mark->SetType(MARK_FILLEDCIRCLE);
//$p1->mark->SetFillColor("red");
//$p1->mark->SetWidth(4);
$graph->Add($p1);
$graph->Stroke();
Yeah...and its the $id that gives me problems. Like, if I specify a
number such as cell 149 instead of $id , it can graph the data points.
Navigation:
[Reply to this message]
|