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");?> Quote Link to comment Share on other sites More sharing options...
Barand Posted April 14, 2013 Share Posted April 14, 2013 (edited) $my_row_totals = array(); while($row = mysqli_fetch_array($result)) { $my_row_totals[] = $row['total'] ; } Why are you storing totals in a database? Edited April 14, 2013 by Barand Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Milka Posted April 16, 2013 Author Share Posted April 16, 2013 Anyone? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 16, 2013 Share Posted April 16, 2013 Anyone? Was there something else? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.