Let me check This, but chances are low because I am using sublime SFTP and I have binded key Ctr+s to server upload so the moment I save them I also automatically upload them to the server.
Also be careful with that echo. If there were no rows retrieved, $data doesnt exist, and json_encode($data) will fail because you’re using $data without definition.
$sql = "SELECT * FROM students";
$result = $conn->query($sql);
// Until proven otherwise, we will assume there are no students
// This makes sure $students is always defined, even when there are no students in the database
$students = [];
// This while loop fetches rows from the database one by one.
// When there are no more records in the database then $result->fetch_assoc()
// returns false, and since an assignment evaluates to the right hand
// side of the assignment the while loop will stop
while ($row = $result->fetch_assoc()) {
// Add the row from the database to our students
$data[] = $row;
}
// Echo'ing JSON Format
echo json_encode($data);