Milka Posted April 14, 2013 Share Posted April 14, 2013 Hi all, This is a bit of a newbie question, I am trying to replace my file array with a mysql array. What I am hoping to do is return all entry's in the "total" table as an array, that I can then input into jpgraph "LinePlot($my-total-array)" How do I return my "total" row as an array that I can use to create my LinePlot($array) Many thanks, M <?phpinclude ("../../jp/src/jpgraph.php");include ("../../jp/src/jpgraph_line.php"); //MySL conn$con=mysqli_connect("db","user","password","testdb");// Check connectionif (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();}$result = mysqli_query($con,"SELECT * FROM testdb");while($row = mysqli_fetch_array($result)){ // //echo . $row['total'] . ; } // JPGRAPH function trim_value(&$value){$value = trim($value);}$Filearray = file("../../array.txt");array_walk($Filearray, 'trim_value');// Create the graph. These two calls are always required$graph = new Graph(750,250,"auto");$graph->SetScale("linelin");$graph->SetMarginColor('#6495ED');$graph->title->Set("totals");$graph->subtitle->Set("all");$graph->xaxis-> title->Set("TIME " );$graph->yaxis-> title->Set("% Total " );$graph->SetShadow();$graph->title->SetColor("white");$graph->subtitle->SetColor("white");$graph->xaxis-> title->SetColor("black");$graph->yaxis-> title->SetColor("black");// Create the linear plot$lineplot=new LinePlot($Filearray);$lineplot->SetColor("red");?> Link to comment https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/ Share on other sites More sharing options...
Barand Posted April 14, 2013 Share Posted April 14, 2013 $my_row_totals = array(); while($row = mysqli_fetch_array($result)) { $my_row_totals[] = $row['total'] ; } Why are you storing totals in a database? Link to comment https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/#findComment-1424687 Share on other sites More sharing options...
Milka Posted April 14, 2013 Author Share Posted April 14, 2013 Hi Barand, Its just the total amount of memory free(total = % of Memory free). Regards, M Link to comment https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/#findComment-1424730 Share on other sites More sharing options...
Milka Posted April 16, 2013 Author Share Posted April 16, 2013 Anyone? Link to comment https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/#findComment-1425030 Share on other sites More sharing options...
Barand Posted April 16, 2013 Share Posted April 16, 2013 Anyone? Was there something else? Link to comment https://forums.phpfreaks.com/topic/276940-mysql-jpgraph-array/#findComment-1425034 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.