<?php
ob_start();
require_once './configs/webconfig.php';
require_once './utility/common_model.php';

require_once './controller/admin_controller.php';

$MyPdodb = new MyPDO();	

		$MyPdodb->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyPDOStatement'));		
		
		
		$sql = "SELECT * from hi_members order by id asc"; 
		
				$stm  = $MyPdodb->prepare($sql);      		
				$stm->execute(array($start,$limit));
				$results = $stm->fetchAll(PDO::FETCH_CLASS);
				
				
				
				$exportData = $results;
if(count($exportData)> 0) {?>Member Id,Family No,Member Name,Name,Gender,Blood Group,Date of Birth,Relation with Member,Marital Status,Education,Occupation,Name of Company,Designation,Address1,Address2,City,State,Country,Zip,Phone No,Website Address,Email Address,Photo file Name<?php				  
                           $i=$start;						   
                          foreach ($exportData as $project) { 							  
                            $i++;	
								for($x=0;$x<$project->nooffamilymembers;$x++){			  							              
									echo "\n".$project->id.",".$project->familyno.",".str_replace(",","",$project->fullname).", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", ";
							    }
						  ?><?php
                           }
                          ?><?php  }else{ ?>No records found.<?php } ?>                  
<?php
$filename = "JPCMemberListtoUploadFamily-".date("dmY").".csv";
header( "Content-Type: application/vnd.ms-excel" );
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
ob_flush();
?>