header('Content-type: application/csv'); //Change File type CSV/TXT etc header('Content-Disposition: attachment; filename=' . $filename); echo $data_op; exit; } //CSV To MYSQL MYADDMINPHP if (isset($_REQUEST['btn_import'])) { define('CSV_PATH', '/var/www/html/gae/csv/'); // specify CSV file path $filename = 'demographic.csv'; $csv_file = CSV_PATH . $filename; // Name of your CSV file $csvfile = fopen($csv_file, 'r'); $sqlinsert = "INSERT INTO demographics (study_id, abs_date, facility_id, anc_id, psc_id, visit_count, " . "anc_visit_date, birth_date, residence, parity, gravida, gestational_period, lmp, edd," . " marital_status, hiv_status, initial_hiv_status, hiv_retest, woman_haart, haart_regimen, " . "counselling, hiv_status_partner, return_date, user_initial) "; $result = $db->importFromCSV($csvfile, $sqlinsert); if ($result > 0) { echo $result . " Total results imported successfully"; } fclose($fp); /*if (!unlink($csv_file)) { echo ("\nError Removing $filename. The file may not exist on the server"); } else { echo ("\nThe file $filename has been removed from the server"); }*/ } ?> </body>
$sqlinsert = $sql_adherence; } if ($_REQUEST['form'] == "variables") { $sqlinsert = $sql_variables; } if ($_REQUEST['form'] == "retention") { $sqlinsert = $sql_retention; } if ($_REQUEST['form'] == "infant_diagnosis") { $sqlinsert = $sql_infant_diagnosis; } if ($_REQUEST['form'] == "anc_followup") { $sqlinsert = $sql_anc_followup; } echo "<h4 class='panel-heading' >"; $db->importFromCSV($handle, $sqlinsert, $_REQUEST['form']); echo "</h4>"; fclose($handle); } else { echo nl2br("File opening failed. Either the file format is wrong or there is not file attached."); } } } ?> <br /> <button type="button" onclick="window.location.href='dashboard.php'" class="btn btn-outline btn-primary btn-xs"><< Back to dashboard</button> </div> </div> </div> </div>