prepare("SELECT saldo AS nominal, bulan AS waktu FROM v_jumlah_transaksi_bulanan WHERE id_data_server = :id "); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->execute(); // Initialize an array to store results $dataArray = []; // Fetch all rows of data while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) { $dataArray[] = $data; // Append each row to the array } // Check if any data was found if (count($dataArray) > 0) { // Return the data as JSON echo json_encode($dataArray); } else { // If no data found, return an error message echo json_encode(['error' => 'Data not found']); } } else { // If API key is missing or invalid echo json_encode(['error' => 'Invalid or missing API key']); } ?>