query($sql); if ($result->num_rows > 0) { // Array to hold the results $rows = array(); while($row = $result->fetch_assoc()) { $servID = $row['service_status_id']; $rows[] = $row; } header('Content-Type: application/json'); echo json_encode($rows); } } // Close connection $conn->close(); ?>