forked from Bkoech/gbvis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
process_aggregates.php
executable file
·126 lines (87 loc) · 3.09 KB
/
process_aggregates.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
//require_once 'includes/global.inc.php';
// Start with collecting from data ///
@$county=$_POST['county'];
@$survey=$_POST['survey'];
@$aggregate_sector=$_POST['sector'];
@$indicator=$_POST['indicator'];
@$aggregates=$_POST['aggregates'];
@$date = date("Y-m-d");
$status_form = "OK";// Set a flag to check
$msg=""; // Message variable
//$row=array("s1"=>"T","s3"=>"T","t1"=>"T","msg"=>"","status_form"=>"OK");
$row=array("s1"=>"T","s2"=>"T","s3"=>"T","t1"=>"T","msg"=>"","status_form"=>"OK");
if(strlen($aggregate_sector) < 1){
$row["status_form"]="NOTOK";
$row["s1"]="F";
$msg .= "Please select county<br>";
}
if(strlen($county) < 1){
$row["status_form"]="NOTOK";
$row["s1"]="F";
$msg .= "Please select county<br>";
}
else if(strlen($survey) < 1)
{
$row["status_form"]="NOTOK";
$row["s2"]="F";
$msg .= "Please select survey<br>";
}
else if(strlen($indicator) < 1){
$row["status_form"]="NOTOK";
$row["s3"]="F";
$msg .= "Please select indicator<br>";
}
else if(strlen($aggregates) < 1)
{
if (!preg_match('/^[0-9]+$/', $aggregates))
{
// contains only 0-9
$row["status_form"]="NOTOK";
$row["t1"]="F";
$msg .= "Enter valid number<br>";
}
}
else
{
$row["status_form"]="OK";
// Database code to go here
$conect = mysql_connect("localhost", "root", "1234");
mysql_select_db("gbvis", $conect);
if($aggregate_sector=1){
$sql = "insert into judiciary_aggregates set county_id='".$county."', survey_id='".$survey."',indicator_id='".$indicator."',aggregate='".$aggregates."'";
$sql = @mysql_query($sql);
}
if($aggregate_sector=2){
$sql = "insert into health_aggregates set county_id='".$county."', survey_id='".$survey."',indicator_id='".$indicator."',aggregate='".$aggregates."'";
$sql = @mysql_query($sql);
}
if($aggregate_sectorr=3){
$sql = "insert into police_aggregates set county_id='".$county."', survey_id='".$survey."',indicator_id='".$indicator."',aggregate='".$aggregates."'";
$sql = @mysql_query($sql);
}
if($aggregate_sector=4){
$sql = "insert into prosecution_aggregates set county_id='".$county."', survey_id='".$survey."',indicator_id='".$indicator."',aggregate='".$aggregates."'";
$sql = @mysql_query($sql);
}
if($aggregate_sector=5){
$sql = "insert into education_aggregates set county_id='".$county."', survey_id='".$survey."',indicator_id='".$indicator."',aggregate='".$aggregates."'";
$sql = @mysql_query($sql);
}
//$db=new DB();
//$aggregateArray = array("county_id" => "'$county'","survey_id" => "' $survey'","indicator_id" => "'$indicator'","aggregate" => "'$aggregates'","date" => "'$date'");
//$insertTable=$db->insert($aggregateArray,"health_aggregates");
if(!$sql)
{
$msg .= "Data Of simlar Details(Indicator,Survey Period,County) Already exist";
}
//echo '<p style="padding:8px; color:red; padding-left:10px; font:normal 12px arial; width:425px; margin: 10px auto 0;">Your enquiry has been submitted successfully. </p>';
else
{
$msg .= "Data Added Successfully";
}
}
$row["msg"]="$msg";
$main = array('data'=>array($row));
echo json_encode($main);
?>