Hi all,

I am hoping someone can help me from my hair pulling.

I am using a class called graphite.php (which I have attached) to generate a
graph,
It pulls the last seven days of hits to a web site from the db and graphs
these as;
Hits (y-axis) vs Day (x-axis) as a line graph.

Unfortunately I am only able to graph the last element in the array. :(

Can anyone explain why ?

Thanks.

Chrisotpher.

Code is below...


<?php
// Graph to display the Last Seven Days Hits...
//----------------------------------------------
include("graphite.php");

//----------------------------------------------
// set the db table variable
//----------------------------------------------
$dbsql = "stats";
$db = mysql_connect("localhost","test","test");
mysql_select_db("logs", $db);
//----------------------------------------------
// SELECT statement to retrieve the count of site visitors
//----------------------------------------------
$sql = "SELECT count(http_x_forwarded_for) as cnt from $dbsql";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$overall = $row["cnt"];
}
//----------------------------------------------
// Daily Averages queries
//----------------------------------------------
echo "Last Seven Daily Averages:<BR>";
$sql = "SELECT count(*) as cnt, DAYNAME(recieved) as dnr,
TO_DAYS(recieved) as tdr
FROM $dbsql
WHERE recieved >= DATE_SUB( CURRENT_DATE, INTERVAL 6 day )
GROUP BY dnr,tdr
ORDER BY tdr";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
echo "$row[dnr] $row[cnt]<BR>";
$day = $row[dnr];
$count = $row[cnt];
}
//----------------------------------------------

$test = new graphite_line();

$test->filename = "mygif.gif";
$test->width = 400;
$test->height = 300;
$test->y_axis_label = "Hits";
$test->y_lables = xrange(0, 20, 1);
$test->x_axis_label = "Days of the Week";
$test->data = array($count);
$test->data_lables = array("$day");

$test->init();

$test->prep();
$test->plot(20);

$test->data = array();
$test->graph_color = ImageColorAllocate($test->image,0,255,0);

$test->prep();
$test->plot(20);
$test->close();

echo "<img src=\"mygif.gif\">";

?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to