forked from dipanshu231099/ADP_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
102 lines (84 loc) · 3.63 KB
/
index.php
File metadata and controls
102 lines (84 loc) · 3.63 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
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
<html>
<head>
<title>Mini project</title>
<link rel="stylesheet" href="main.css">
<script>
function ajax(){
var max = document.getElementById("max").checked;
var min = document.getElementById("min").checked;
var avg = document.getElementById("avg").checked;
var str="";
if(max){str+="max"};
if(min){str+="min"};
if(avg){str+="avg"};
var from_date = document.getElementById("from_date").value;
var to_date = document.getElementById("to_date").value;
var field = document.getElementById("field").value;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "gethint.php?from_date=" + from_date + "&to_date="+to_date+"&field="+field+"&q="+str, true);
xmlhttp.send();
}
</script>
</head>
<body>
<h1>Using php</h1>
<method1>
<form action="result.php" method="POST">
<label for="from_date">From: </label>
<input type="date" name="from_date">
<label for="to_date">To: </label>
<input type="date" name="to_date"><br><br>
<div class="dropdown">
<select name="field" style="color: white'; background-color:black;">
<?php
$conn = mysqli_connect('localhost','dipanshu','dipanshu23','project');
$result = $conn -> query("DESC pollution_data");
while($row = mysqli_fetch_array($result)) {
echo "<option value='".$row['Field']."'>".$row['Field']."</option>";
}
?>
</select>
</div>
<br>
<button type="submit">Submit Query</button>
<br><br>
<label for="max">Maximum: </label> <input type="checkbox" name="max">
<label for="min">Minimum: </label> <input type="checkbox" name="min" id="">
<label for="avg">Average: </label> <input type="checkbox" name="avg">
</form>
</method1>
<h1>Using Ajax</h1>
<method2>
<form>
<label for="from_date">From: </label>
<input type="date" name="from_date" id="from_date">
<label for="to_date">To: </label>
<input type="date" name="to_date" id="to_date"><br><br>
<div class="dropdown">
<select name="field" style="color: white'; background-color:black;" id="field">
<?php
$conn = mysqli_connect('localhost','dipanshu','dipanshu23','project');
$result = $conn -> query("DESC pollution_data");
while($row = mysqli_fetch_array($result)) {
echo "<option value='".$row['Field']."'>".$row['Field']."</option>";
}
?>
</select>
</div>
<br>
<label for="max">Maximum: </label> <input type="checkbox" name="max" id="max" value="dipanshu">
<label for="min">Minimum: </label> <input type="checkbox" name="min" id="min" value="dipanshu">
<label for="avg">Average: </label> <input type="checkbox" name="avg" id="avg" value="dipanshu">
<br><br>
<input type="button" value="Submit Query Ajax" onclick="ajax()">
<br><br>
<p id="txtHint"></p>
</form>
</method2>
</body>
</html>