Reputation: 308
So i have setup the code to display graph from php sql. But i cant seem to order it by todays date from a timestamp in my table. Here is my code:
<?php
include("phpgraphlib.php");
$graph=new PHPGraphLib(550,450);
$link = mysql_connect('xxx', 'xxx', 'xxx')
or die('Could not connect: ' . mysql_error());
mysql_select_db('test') or die('Could not select database');
$dataArray=array();
//get data from database
// $sql="SELECT rating, COUNT(*) AS 'datentry' FROM main_table GROUP BY rating";
$sql="SELECT rating, COUNT(*) AS 'datentry' FROM main_table GROUP BY rating";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$salesgroup=$row["rating"];
$count=$row["datentry"];
//add to data areray
$dataArray[$salesgroup]=$count;
}
}
//configure graph
$graph->addData($dataArray);
$graph->setTitle("Daily");
$graph->setGradient("lime", "green");
$graph->setBarOutlineColor("black");
$graph->createGraph();
?>
What i want to achieve is to be able to display just todays data. This specific code displays all of the data in my table.
Upvotes: 0
Views: 149