<?php
include("../inc/config.php");
            	
	$now = gmdate("YmdHis");
		header('Content-Type: text/csv; charset=utf-8');  
		header('Content-Disposition: attachment; filename=Pincode-list-'.$now.'.csv');  
		$output = fopen("php://output", "w");  
		fputcsv($output, array('SL','Pincode', 'City', 'State', 'Service', 'Air', 'Road', 'B2B', 'B2C', 'ODA'));  
        $i=1;
        	$statement = $pdo->prepare("SELECT * FROM pincode");	 
            $statement->execute();
            $result = $statement->fetchAll(PDO::FETCH_ASSOC);
            foreach($result as $row)
            {
            	fputcsv($output, array($i,$row['pin_code'],$row['city'],$row['state'],$row['service'],$row['air'],$row['road'],$row['b2b'],$row['b2c'],$row['oda']));
    		    $i++;
            }
		fclose($output);
?>