ok
Direktori : /home2/selectio/www/wedding-info/api/csv/ |
Current File : /home2/selectio/www/wedding-info/api/csv/wedding-matching-upload-data.php |
<?php include '../config/config.php'; $now = gmdate("YmdHis"); header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=Bulk Insert & Update Rasi Star Matching.csv'); $output = fopen("php://output", "w"); $sql = "SELECT column_name FROM information_schema.columns WHERE table_name ='tbl_rasi_star_matching' "; $stmt = $pdo->prepare($sql); $stmt->execute([$table]); $columns=$stmt->fetchAll(PDO::FETCH_COLUMN); $header_columns=array(); $r=1; foreach($columns as $cols){ if($r!=1){ $header_columns[]= ucwords(str_replace("_"," ",$cols)); } $r++; } fputcsv($output, $header_columns); $statement = $pdo->prepare("SELECT * FROM `tbl_rasi_star_matching`"); $statement->execute(); $row_data = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($row_data as $rs){ unset($rs['id']); fputcsv($output, $rs); } fclose($output); ?>