-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaddID.php
More file actions
32 lines (32 loc) · 1.04 KB
/
addID.php
File metadata and controls
32 lines (32 loc) · 1.04 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
<?php
$studentID = $_GET['studentID'];
$appID = $_GET['appID'];
$programID = $_GET['programID'];
$outp ="[";
$con=mysqli_connect("127.0.0.1","root","","project_test");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "UPDATE student SET StudentID ='".$studentID."' WHERE AppID ='".$appID."'";
$con->query($sql);
$con->close();
$conn=mysqli_connect("127.0.0.1","root","","project_test");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT AppID, StudentID, fName, lName FROM student WHERE ProgramID ='".$programID."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"AppID":"'. $row["AppID"].'",';
$outp .= '"StudentID":"'. $row["StudentID"].'",';
$outp .= '"fName":"'. $row["fName"].'",';
$outp .= '"lName":"'. $row["lName"]. '"}';
}
}
$outp.="]";
$conn->close();
echo ($outp)
?>