PHP interesse |
|
Ik probeer met het volgende stuk script een array te voeren naar jpgraph.
Echter krijg ik nu met dit script continu 1 waarde "1".
Zou iemand hier meer info over weten ?
<?php
include ("jpgraph-1.20.4/src/jpgraph.php");
include ("jpgraph-1.20.4/src/jpgraph_bar.php");
$host = "";
$user = "";
$bdd = "";
$password = "";
mysql_connect($host, $user,$password) or die("erreur de connexion au serveur");
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
$data1y = "";
$tellerledenday = date('d');
$tellerledenmonth = date('m');
$tellerledenyear = date('y');
if($tellerledenmonth=="01"){ $maxday = 31; }
elseif($tellerledenmonth=="02"){ $maxday = 28; }
elseif($tellerledenmonth=="03"){ $maxday = 31; }
elseif($tellerledenmonth=="04"){ $maxday = 30; }
elseif($tellerledenmonth=="05"){ $maxday = 31; }
elseif($tellerledenmonth=="06"){ $maxday = 30; }
elseif($tellerledenmonth=="07"){ $maxday = 31; }
elseif($tellerledenmonth=="08"){ $maxday = 31; }
elseif($tellerledenmonth=="09"){ $maxday = 30; }
elseif($tellerledenmonth=="10"){ $maxday = 31; }
elseif($tellerledenmonth=="11"){ $maxday = 30; }
else { $maxday = 31; }
$aantal = $maxday;
for($a=1;$a<=$aantal;$a++){
if($a<=9) { $dag = "0" . $a; } else { $dag = $a; }
$query = "SELECT SUM(hits) AS hits FROM ledenstats WHERE toid = '1' AND day = '$dag' AND month = '$tellerledenmonth' AND year = '$tellerledenyear' ORDER BY time DESC";
$result = mysql_fetch_assoc(mysql_query($query));
if($result["hits"] == "") {
$hits = 0;
} else {
$hits = $result["hits"];
}
$hit = "".$hits.",";
$data1ytemp .= $hit;
}
$data1y = "".$data1ytemp."0";
//echo $data1y;
//echo $data1y;
// Create the graph. These two calls are always required
$graph = new Graph(480,200,"auto");
$graph->SetScale("textlin");
//$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);
$graph->SetBackgroundImage("jpgraph-1.20.4/src/Examples/tiger_bkg.png",BGIMG_COPY);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillGradient("forestgreen","springgreen",GRAD_HOR);
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$graph->title->Set("Profielbezoek");
$graph->xaxis->title->Set("Dag");
$graph->yaxis->title->Set("Aantal");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
// Display the graph
$graph->Stroke();
?>
<?php include ("jpgraph-1.20.4/src/jpgraph.php"); include ("jpgraph-1.20.4/src/jpgraph_bar.php"); $host = ""; $user = ""; $bdd = ""; $password = ""; $data1y = ""; $tellerledenday = date('d'); $tellerledenmonth = date('m'); $tellerledenyear = date('y'); if($tellerledenmonth=="01"){ $maxday = 31; } elseif($tellerledenmonth=="02"){ $maxday = 28; } elseif($tellerledenmonth=="03"){ $maxday = 31; } elseif($tellerledenmonth=="04"){ $maxday = 30; } elseif($tellerledenmonth=="05"){ $maxday = 31; } elseif($tellerledenmonth=="06"){ $maxday = 30; } elseif($tellerledenmonth=="07"){ $maxday = 31; } elseif($tellerledenmonth=="08"){ $maxday = 31; } elseif($tellerledenmonth=="09"){ $maxday = 30; } elseif($tellerledenmonth=="10"){ $maxday = 31; } elseif($tellerledenmonth=="11"){ $maxday = 30; } else { $maxday = 31; } $aantal = $maxday; for($a=1;$a<=$aantal;$a++){ if($a<=9) { $dag = "0" . $a; } else { $dag = $a; } $query = "SELECT SUM(hits) AS hits FROM ledenstats WHERE toid = '1' AND day = '$dag' AND month = '$tellerledenmonth' AND year = '$tellerledenyear' ORDER BY time DESC"; if($result["hits"] == "") { $hits = 0; } else { $hits = $result["hits"]; } $hit = "".$hits.","; $data1ytemp .= $hit; } $data1y = "".$data1ytemp."0"; //echo $data1y; //echo $data1y; // Create the graph. These two calls are always required $graph = new Graph(480,200,"auto"); $graph->SetScale("textlin"); //$graph->SetShadow(); $graph->img->SetMargin(40,30,20,40); $graph->SetBackgroundImage("jpgraph-1.20.4/src/Examples/tiger_bkg.png",BGIMG_COPY); // Create the bar plots $b1plot = new BarPlot($data1y); $b1plot->SetFillGradient("forestgreen","springgreen",GRAD_HOR); // Create the grouped bar plot $gbplot = new GroupBarPlot (array($b1plot)); // ...and add it to the graPH $graph->Add($gbplot); $graph->title->Set("Profielbezoek"); $graph->xaxis->title->Set("Dag"); $graph->yaxis->title->Set("Aantal"); $graph->title->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); // Display the graph $graph->Stroke(); ?>
TABLE :
CREATE TABLE `ledenstats` (
`id` int(20) NOT NULL auto_increment,
`toid` int(11) NOT NULL default '1',
`fromid` int(11) NOT NULL default '1',
`hits` int(20) NOT NULL default '1',
`time` int(5) NOT NULL default '0',
`day` char(2) NOT NULL default '',
`month` char(2) NOT NULL default '',
`year` char(2) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=40486 ;
CREATE TABLE `ledenstats` ( `id` int(20) NOT NULL auto_increment, `toid` int(11) NOT NULL default '1', `fromid` int(11) NOT NULL default '1', `hits` int(20) NOT NULL default '1', ` time` int (5) NOT NULL default '0',`day` char(2) NOT NULL default '', `month` char(2) NOT NULL default '', `year` char(2) NOT NULL default '', ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=40486 ;
|