MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
Upload Files
File: //home/jibhires/demo.brightsolutionsindia.com/images/export_csv.php
<?php
include 'db_connect.php';

header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=qc_report.csv');

// Fetch QC sheet data
$query = "SELECT qc_sheets.id, machines.machine_name, users.username AS operator, qc_sheets.qc_date, qc_sheets.status 
          FROM qc_sheets 
          JOIN machines ON qc_sheets.machine_id = machines.id 
          JOIN users ON qc_sheets.operator_id = users.id";
$stmt = $pdo->query($query);
$qc_sheets = $stmt->fetchAll();

// Open output stream
$output = fopen('php://output', 'w');

// Output the column headings
fputcsv($output, array('QC Sheet ID', 'Machine', 'Operator', 'Date', 'Status'));

// Output the rows
foreach ($qc_sheets as $qc_sheet) {
    fputcsv($output, $qc_sheet);
}

fclose($output);
exit;
?>