query($sql); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $row['bill_file_name'] . '"'); ob_clean(); echo $row['bill_file']; exit; } else { echo "Document not found"; } }