-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.php
More file actions
54 lines (44 loc) · 1.52 KB
/
graph.php
File metadata and controls
54 lines (44 loc) · 1.52 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
//$candidate=$_GET['user'];
//$candidate="Romney";
$candidate= $_POST['vehicle'];
//if(($candidate=="Romney")||($candidate=="Paul")||($candidate=="Santorum")||($candidate=="Gingrich")) {
include("phpgraphlib.php");
$graph=new PHPGraphLib(550,350);
$link = mysql_connect('18.194.1.88:3306', 'TMG6470', 'snett')
or die('Could not connect: ' . mysql_error());
mysql_select_db('candidates_2012') or die('Could not select database');
$dataArray=array();
for($i=0;$i<count($candidate); $i++) {
$data.$i=array();
//$candidate=$_POST[value];
//get data from database
$sql="SELECT $candidate[$i],Date FROM gallup_poptime";
//$dates="SELECT Date FROM gallup_poptime";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
//$result2 = mysql_query($dates) or die('Query failed: ' . mysql_error());
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$salesgroup=$row["$candidate[$i]"];
$dates=$row["Date"];
//$date=$result2[$count];
//add to data array
$data.$i[$dates]=$salesgroup;
}
}
}
//print_r($dataArray);
$graph->addData($data1,$data2,$data3,$data4);
$graph->setTitle("Popularity");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
//$graph->setDataValues(true);
//$graph->setDataValueColor('maroon');
$graph->setGoalLine(.0025);
$graph->setGoalLineColor('red');
$graph->createGraph();
//}
//else echo "Please try again and submit the last name of a major presidential candidate but not the current incumbent.";
?>