Your file is ready and now you can <a href="witnessrep_taggen.csv" type="application/octet-stream">download</a><br /><br />
<a href="pat_3.php">Click here to go back....</a>
<?php
$comp = $_GET['co'] ?? ''; 
//$DPC_date1 = $_POST['DPC_date1']; 
$DPC_date1 = "01/12/2022"; 
//$DPC_date2 = $_POST['DPC_date2']; 
$DPC_date2 = "31/12/2024"; 
$DPC_date1 = stripslashes($DPC_date1);
$datex=$DPC_date1[6].$DPC_date1[7].$DPC_date1[8].$DPC_date1[9].'-'.$DPC_date1[3].$DPC_date1[4].'-'.$DPC_date1[0].$DPC_date1[1];
$DPC_date2 = stripslashes($DPC_date2);
$datey=$DPC_date2[6].$DPC_date2[7].$DPC_date2[8].$DPC_date2[9].'-'.$DPC_date2[3].$DPC_date2[4].'-'.$DPC_date2[0].$DPC_date2[1];
include 'config.php';
$result = mysqli_query($conn, "SELECT reslt_dt, ent_by, LEFT(chn_cycle, 8),
case grpbypid
		WHEN 'a1' THEN 'IVF/ICSI'
		WHEN 'a2' THEN 'Sperm assessment and preparation'
end grpbypid,
case process_main_id
		WHEN 'a1:b01' THEN 'Pool dish (35mm Dish)'
        WHEN 'a1:b02' THEN 'Post Denudation dish (60 mm Dish)'
        WHEN 'a1:b03' THEN 'ICSI Dish'
        WHEN 'a1:b04' THEN 'Fert dish (D0)'
        WHEN 'a1:b05' THEN 'Cleave dish (D1)'
        WHEN 'a1:b06' THEN 'Blast Dish(D3)'
        WHEN 'a1:b07' THEN 'Blast Dish(D5/6)'
        WHEN 'a1:b08' THEN 'ET Dish'
        WHEN 'a1:b09' THEN 'PGT Biopsy Dish'
        WHEN 'a1:b10' THEN 'Post thaw culture dish'
        WHEN 'a2:b01' THEN 'Semen Collection container'
        WHEN 'a2:b02' THEN 'DG Tube/ Swim up Tube'
        WHEN 'a2:b03' THEN 'Post wash tube'
end process_main_id FROM matcher_tag_gen where reslt_dt>='$datex' AND reslt_dt<='$datey' ORDER BY reslt_dt");
if (!$result) die('Couldn\'t fetch records');
$csv_fields=array();
$csv_fields[] = 'Date / Time';
$csv_fields[] = 'Entry by';
$csv_fields[] = 'Patient MRN';
$csv_fields[] = 'Tag Group';
$csv_fields[] = 'Tag generated for';
$fp = fopen('witnessrep_taggen.csv', 'w');
if ($fp && $result) {
fputcsv($fp, $csv_fields);
    while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
        fputcsv($fp, array_values($row));
    }
//    die;
}
fclose($fp);
?>
