<?php require_once('../Connections/BE2.php'); ?>
<?  require('system/login.php');  ?>
<?php
mysql_select_db($database_BE2, $BE2);
//$query_Rt2 = "SELECT * FROM signup1 WHERE 1 ORDER BY sgid DESC";
$query_Rt2 = sprintf("SELECT a.sgname,b.* FROM signup1 as a left join signupman as b on a.sgid=b.sgid where b.sgid='%s' order by b.randw,b.ma ASC",$_GET['editid']);
$Rt2 = mysql_query($query_Rt2,  $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
//echo '媒體 17 活動 16 最新 15';
//echo $query_Rt2;

$title =$row_Rt2['sgname']."(".date('Ymd',time()).")報名人數表.csv";
 header("Content-type:application/vnd.ms-excel");
 //header("Content-Disposition:filename=".iconv("UTF-8","BIG5" ,$title));
 header("Content-Disposition:filename=". $title );
$page_head ="活動名稱 , 報名 , 姓名 , 身分證號 , 出生年月日 ,年齡 ,性別 ,血型 , 葷素, 連絡電話, 手機 , 聯絡地址 , 學歷 , LINEID , 職業 , E-mail , 報名日期 , 報名人數 , 審核 , 狀態 \n";
//echo iconv("UTF-8","BIG5" ,$page_head);
echo  $page_head ;
 do { 
 if($row_Rt2['ma']==0){
 $str = $row_Rt2['sgname'].", 報名者 ,".$row_Rt2['s1'].",".$row_Rt2['s2'].",".$row_Rt2['s3'].",";
 $str .= $row_Rt2['s4'].",".$row_Rt2['s5'].",".$row_Rt2['s6'].",".$row_Rt2['s7'].",".$row_Rt2['s8'].",".$row_Rt2['s9'].",".$row_Rt2['s10'].",".$row_Rt2['s11'].",".$row_Rt2['s12'].",".$row_Rt2['s13'].",".$row_Rt2['s14'];
 $str .= ",".$row_Rt2['sdate'].",".$row_Rt2['cman'].",".(($row_Rt2['ck']==1)?"已審":"" ).",".(($row_Rt2['ck2']==1)?"未審":"")."\n";
 }else{
	 
 $str = " , 攜伴 ,".$row_Rt2['s1'].",".$row_Rt2['s2'].",".$row_Rt2['s3'].",";
 $str .= $row_Rt2['s4'].",".$row_Rt2['s5'].",".$row_Rt2['s6'].",".$row_Rt2['s7'].",".$row_Rt2['s8'].",".$row_Rt2['s9'].",".$row_Rt2['s10'].",".$row_Rt2['s11'].",".$row_Rt2['s12'].",".$row_Rt2['s13'].",".$row_Rt2['s14'];
 $str .= ", , ,".(($row_Rt2['ck']==1)?"已審":"" ).",".(($row_Rt2['ck2']==1)?"未審":"")."\n";
 
	 
	 
	 }
 
 
 //s1	s2	s3	s4	s5	s6	s7	s8	s9	s10	s11	s12	s13	s14	sdate	cman	ck	ck2	
 // echo iconv("UTF-8","BIG5" ,$str);
  
    echo $str;
    } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?>

<?php
mysql_free_result($Rt2);
?>
