<?php
session_start();
require_once '../connection.php';

if (!isset($_SESSION['admin_id'])) {
    die('Unauthorized');
}

// Get filters from URL
$status = $_GET['status'] ?? 'all';
$crypto = $_GET['crypto'] ?? 'all';
$date = $_GET['date'] ?? '';

// Build query (similar to main page)
// ... (implement export logic)

// Set headers for CSV download
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="mining-data.csv"');

// Output CSV data
$output = fopen('php://output', 'w');
fputcsv($output, ['User', 'Crypto', 'Amount', 'Profit %', 'Profit $', 'Total Return', 'Status', 'Start Time', 'End Time']);

// Fetch and output data
// ...

fclose($output);
?>