"; */ require_once("config/datenbankanbindung.php"); // fügt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php $user = $_GET['user']; # Sonst Probleme bei Leerzeichen (Doppelnamen) $nachname = str_replace('|', ' ', $_GET['nachname']); $vorname = str_replace('|', ' ', $_GET['vorname']); require ("./jpgraph/src/jpgraph.php"); require ("./jpgraph/src/jpgraph_bar.php"); require ("./jpgraph/src/jpgraph_line.php"); $db = dbconnect(); $query = "SELECT distinct date_format(Datum, '%Y%m') datum FROM userlog WHERE date_format(datum, '%Y%m')>=date_format(DATE_SUB(NOW(), INTERVAL 11 MONTH), '%Y%m') ORDER BY datum asc "; $result = $db->query( $query) or die ("Cannot execute query"); while ($row = $result->fetch_array()){ $result2 = $db->query("SELECT distinct replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(date_format(datum, '%M %Y'), 'January', 'Jan'), 'February','Feb'),'March','Mär'),'April','Apr'),'May','Mai'),'June','Jun'),'July','Jul'),'August','Aug'),'September','Sep'),'October','Okt'),'November','Nov'),'December','Dez') Monat, count(*) anz FROM userlog WHERE date_format(datum, '%Y%m') = '$row[datum]' AND uid = '$user' GROUP BY Monat"); $row2 = $result2->fetch_array(); if($row2['anz'] == ''){ $anzahl = 0; }else{ $anzahl = $row2['anz']; } $ydata[] = $anzahl; $ydata2[] = $anzahl; # gleiche Abfrage nochmals ohne Eingrenzung auf Benutzer, damit die Monatsachse vollständig ausgefüllt wird, auch wen der User in einem Monat keine Anmeldung hatte $result2 = $db->query("SELECT distinct replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(date_format(datum, '%M %Y'), 'January', 'Jan'), 'February','Feb'),'March','Mär'),'April','Apr'),'May','Mai'),'June','Jun'),'July','Jul'),'August','Aug'),'September','Sep'),'October','Okt'),'November','Nov'),'December','Dez') Monat, count(*) anz FROM userlog WHERE date_format(datum, '%Y%m') = '$row[datum]' GROUP BY Monat"); $row2 = $result2->fetch_array(); $months[] = "$row2[Monat]"; } // Some "random" data ## Balken und Linien #$ydata = $data; #$ydata2 = $data; #exit; // Get a list of month using the current locale #$months = $gDateLocale->GetShortMonth(); #$months = array('1','3'); // Create the graph. $graph = new Graph(320,200); $graph->SetScale("textlin"); $graph->SetMarginColor('white'); // Adjust the margin slightly so that we use the // entire area (since we don't use a frame) $graph->SetMargin(40,10,40,45); // Box around plotarea $graph->SetBox(); // No frame around the image $graph->SetFrame(false); // Setup the tab title $graph->tabtitle->Set("Statistik $vorname $nachname"); $graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10); // Setup the X and Y grid $graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5'); $graph->ygrid->Show(); $graph->xgrid->Show(); // Setup month as labels on the X-axis $graph->xaxis->SetTickLabels($months); $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6); #$graph->xaxis->SetLabelAlign('center','top','center'); $graph->xaxis->SetLabelAngle(45); $graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,7); // Create a bar pot $bplot = new BarPlot($ydata); $bplot->SetWidth(0.6); $fcol='#440000'; $tcol='#FF9090'; $bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION); // Set line weigth to 0 so that there are no border // around each bar $bplot->SetWeight(0); $graph->Add($bplot); // Create filled line plot $lplot = new LinePlot($ydata2); $lplot->SetFillColor('skyblue@0.7'); $lplot->SetColor('navy@0.5'); $lplot->SetBarCenter(); $lplot->mark->SetType(MARK_SQUARE); $lplot->mark->SetColor('blue@0.7'); $lplot->mark->SetFillColor('lightblue'); $lplot->mark->SetSize(3); $graph->Add($lplot); // .. and finally send it back to the browser $graph->Stroke(); ?>