query($sql); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { $seq = $row['sequence']; switch ($seq) { case 1: $qa =$row['question']; break; case 2: $qb =$row['question']; break; case 3: $qc =$row['question']; break; } } } $srv="SELECT t1.id AS serviceID,t1.car_plate,t1.dealer_id,t1.date,t1.assigned_service_advisor,t2.name AS DealName, t2.id AS dealID,t3.id AS hrUserID,t3.first_name,t3.last_name FROM autoph_ahg_crm.service_bookings t1 LEFT JOIN autoph_ahg_crm.dealerships t2 ON t1.dealer_id = t2.id LEFT JOIN autoph_ahg_hr.users t3 ON t1.assigned_service_advisor = t3.employee_id WHERE t1.id = $serviceID LIMIT 1"; $resultS = $conn->query($srv); if ($resultS->num_rows > 0) { while($rowV = $resultS->fetch_assoc()) { $carPlate =$rowV['car_plate']; $dealName =$rowV['DealName']; $saName =$rowV['last_name'].", ". $rowV['first_name']; $date =$rowV['date']; } } // Output the result in JSON format header('Content-Type: application/json'); $openText = "Users comment in open text format"; echo json_encode([ "QuestionA" => "$qa", "QuestionB" => "$qb", "QuestionC" => "$qc", "openText" => "$openText", "carPlate" => "$carPlate", "dealName" => "$dealName", "saName" => "$saName", "date" => "$date", ]); } // Close connection $conn->close(); ?>