forked from titat/project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetTable.php
More file actions
24 lines (24 loc) · 797 Bytes
/
getTable.php
File metadata and controls
24 lines (24 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$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 = "SELECT AppID, ProgramID, StudentID, fName, lName FROM student WHERE ProgramID ='".$programID."'";
$result = $con->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 .= '"ProgramID":"'. $row["ProgramID"].'",';
$outp .= '"StudentID":"'. $row["StudentID"].'",';
$outp .= '"fName":"'. $row["fName"].'",';
$outp .= '"lName":"'. $row["lName"]. '"}';
}
}
$outp.="]";
$con->close();
echo ($outp)
?>