-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDownload.php
executable file
·213 lines (189 loc) · 9.09 KB
/
Download.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-black.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--bootstrapCDN-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP VmmDGMN5t9UJ0Z" crossorigin="anonymous"/>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C OGpamoFVy38MVBnE IbbVYUew OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU 6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV rV" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/ReferenceNotes.css" >
<title>Download Question Paper</title>
<style>
table{
color: #588c7e;
font-family: monospace;
font-size: 25px;
text-align: left;
}
th{
color: #003434;
}
</style>
<!--js for dropdowns-->
<script>
var subjectObject = {
"1": {
"CSE": ["Maths", "Physics", "Chemistry", "Mechanics", "BES", "Computer programming"],
"ECE": ["Maths", "Physics", "Chemistry", "Mechanics", "BES", "Computer programming"],
"CE": ["Maths", "Physics", "Chemistry", "Mechanics", "BES", "Computer programming"],
"CH": ["Maths", "Physics", "Chemistry", "Mechanics", "BES", "Computer programming"]
},
"2": {
"CSE": ["Maths", "Logic Design", "Program Design", "Discrete Structures", "Computer Organization", "DSA"],
"CE": ["Mechanics of solids", "Surveying", "Mechanics of fluids", "Building Technology", "Structural analysis"],
"MSE": ["Structure of materials", "Thermodynamics", "Fluid mechanics", "Heat transfer"],
"CH": ["Mechanical Operations", "Material Science", "Heat Transfer", "Fluid Mechanics", "Chemical Technology", "Process Calculations", "Thermodynamics"]
},
"3": {
"CSE": ["PPL", "Theory of Computation", "Database Management Systems", "Operating Systems"],
"CE": ["Structural design", "Numericsl methods", "Transportation engineering", "Structural analysis"],
"MSE": ["Thermal engineering", "Semiconductors nanostructures", "Bio-materials"],
"CH": ["Mass Transfer", "Process Dynamics and Control", "Chemical Reaction Engineering","Thermodynamics","Petroleum Refining Operations AND Processes"]
},
"4": {
"CSE": ["Artificial Intelligence", "ML"],
"CE": ["Environmental engineering", "Construction management", "Water resource engineering"],
"MSE": ["Energy materials and technology", "Corrosion science and engineering", "Industrial Economics"],
"CH": ["Transport Phenomena", "Chemical Process Optimization" ,"Computer Aided Design"]
}
}
window.onload = function() {
var YearSel = document.getElementById("Year");
var BranchSel = document.getElementById("Branch");
var SubjectSel = document.getElementById("Subject");
for (var x in subjectObject) {
YearSel.options[YearSel.options.length] = new Option(x, x);
}
YearSel.onchange = function() {
//empty Subject- and Branch dropdowns
SubjectSel.length = 1;
BranchSel.length = 1;
//display correct values
for (var y in subjectObject[this.value]) {
BranchSel.options[BranchSel.options.length] = new Option(y, y);
}
}
BranchSel.onchange = function() {
SubjectSel.length = 1;
//display correct values
var z = subjectObject[YearSel.value][this.value];
for (var i = 0; i < z.length; i ) {
SubjectSel.options[SubjectSel.options.length] = new Option(z[i], z[i]);
}
}
}
</script>
</head>
<body class="ref-bg">
<!-- Navbar -->
<div class="w3-top">
<div class="w3-bar w3-theme-d2 w3-left-align">
<a class="w3-bar-item w3-button w3-hide-medium w3-hide-large w3-right w3-hover-white w3-theme-d2" href="javascript:void(0);" onclick="openNav()"><i class="fa fa-bars"></i></a>
<a href="HomePage.php" class="w3-bar-item w3-button"><i class="fa fa-home w3-margin-right"></i>NITC Question Bank</a>
<a href="#QnPaper" class="w3-bar-item w3-button w3-hide-small w3-hover-white w3-teal">QPaper</a>
<a href="HomePage.php#ElectiveInfo" class="w3-bar-item w3-button w3-hide-small w3-hover-white">Elective Info</a>
<a href="HomePage.php#PlacementInfo" class="w3-bar-item w3-button w3-hide-small w3-hover-white">Placement Info</a>
<button onclick="document.getElementById('id01').style.display='block'" class="w3-button w3-theme w3-hover-teal">Notifications</button>
</div>
<!-- Navbar on small screens -->
<div id="navDemo" class="w3-bar-block w3-theme-d2 w3-hide w3-hide-large w3-hide-medium">
<a href="#QnPaper" class="w3-bar-item w3-button">QPaper</a>
<a href="#ElectiveInfo" class="w3-bar-item w3-button">Elective Info</a>
<a href="#PlacementInfo" class="w3-bar-item w3-button">Placement Info</a>
</div>
</div>
<div class = "w3-padding-64">
<h1 class = "text-center text-white">Download Question Paper</h1>
<!--choosing year, branch and subjects-->
<div class="w3-card-4 download-card">
<form method="post" enctype="multipart/form-data">
<div>
<h1 class = "qpHeading">Enter the details</h1>
<h4 class="qpDetails">Year </h4>
<select class = "dropdowns" name="Year" id="Year">
<option value="" selected="selected">Select Year</option>
</select>
<h4 class="qpDetails">Branch </h4>
<select class = "dropdowns" name="Branch" id="Branch">
<option value="" selected="selected">Select Branch</option>
</select>
<h4 class="qpDetails">Subject </h4>
<select class = "dropdowns" name="Subject" id="Subject">
<option value="" selected="selected">Please select Branch first</option>
</select>
</div>
<div class="col-12 d-flex flex-row justify-content-center">
<button type="submit" class="download-button" name= "Submit4"> Download Question Paper </button>
</div>
</form>
<?php
if(isset($_POST['Submit4']))
{
// Connect to the database
$dbLink = new mysqli('localhost', 'root', '', 'Nitcq');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
$Branch=$_POST['Branch'];
$Year=$_POST['Year'];
$Subject=$_POST['Subject'];
// Query for a list of all existing files
$sql = "SELECT `Qp_no`, `Qp_name`, `Branch`, `Year`, `Subject` FROM `Question_paper` WHERE '$Branch'=`Branch` AND '$Year'= `Year` AND '$Subject' = `Subject`";
$result = $dbLink->query($sql);
// Execute the query
if($result=$dbLink->query($sql)) {
//chech if the database is empty
if($result->num_rows == 0)
{
echo '<p>There are no files in the database</p>';
}
else
{
// Print the column heading of the table
echo '<table width="100%">
<tr>
<th><b>Qp_name</b></th>
<th><b>Branch</b></th>
<th><b>Year</b></th>
<th><b>Subject</b></th>
<th><b> </b></th>
</tr>';
// Print each file
echo nl2br("\n");
echo nl2br("\n");
while($row = $result->fetch_assoc())
{
echo "
<tr>
<td>{$row['Qp_name']}</td>
<td>{$row['Branch']}</td>
<td>{$row['Year']}</td>
<td>{$row['Subject']}</td>
<td><a href='get_file.php?Qp_no={$row['Qp_no']}'><button>Download</button></a></td>
</tr>";
}
// Close table
echo '</table>';
}
// Free the result
$result->free();
}
else
{
echo 'Error! SQL query failed:';
echo "<pre>{$dbLink->error}</pre>";
}
// Close the mysql connection
$dbLink->close();
}
?>
</div>
</div>
<script src="js/qnpaper-upload.js"></script>
</body>
</html>