-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgraph.php
More file actions
executable file
·55 lines (42 loc) · 1.23 KB
/
graph.php
File metadata and controls
executable file
·55 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
//Print_r ($_SESSION);
include("settings.php");
$conn=mysql_connect('localhost',$DBUSER,$DBPASS);
$username=$_SESSION['username'];
mysql_select_db($DBNAME,$conn);
$php = "[['Contest', 'Score']";
$score=0;
$i=0;
$j=1;
$query="SELECT count(*) as c from contests";
$logged=mysql_query($query);
$r1=mysql_fetch_array($logged);
$contestcount=$r1['c'];
for($j=1;$j<=$contestcount;$j+=1)
{ $query="SELECT score from contest_$j where userID=".$newuserid;
$logged=mysql_query($query);
$r1=mysql_fetch_array($logged);
if(!$r1)continue;
$score=$r1['score'];
$query="SELECT Name from contests where contestID=$j";
$logged=mysql_query($query);
$r2=mysql_fetch_array($logged);
$named=$r2['Name'];
$php.= ",['$named',$score]";
}
$php.="]";
echo $php;
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(<?php echo $php; ?>);
var options = {
title: 'Your Performance [Score vs Contest]'
};
var chart = new google.visualization.LineChart(document.getElementById('graph1'));
chart.draw(data, options);
}
</script>