<?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()).")報名人數表.xls";
 header("Content-type:application/vnd.ms-excel");
 header("Content-Disposition:filename=".iconv("UTF-8","BIG5" ,$title));

$page_head ="活動名稱 \t 報名 \t 姓名 \t 身分證號 \t 出生年月日 \t年齡 \t性別 \t血型 \t 葷素\t 連絡電話\t 手機 \t聯絡地址 \t緊急連絡人 \t學校 \t 單位\t E-mail \t 報名日期 \t 報名人數 \t 審核 \t 狀態 \t\n";
echo iconv("UTF-8","BIG5" ,$page_head);

 do { 
 if($row_Rt2['ma']==0){
 $str = $row_Rt2['sgname']."\t 報名者 \t".$row_Rt2['s1']."\t".$row_Rt2['s2']."\t".$row_Rt2['s3']."\t";
 $str .= $row_Rt2['s4']."\t".$row_Rt2['s5']."\t".$row_Rt2['s6']."\t".$row_Rt2['s7']."\t".$row_Rt2['s8']."\t".$row_Rt2['s9']."\t".$row_Rt2['s10']."\t".$row_Rt2['s11']."\t".$row_Rt2['s12']."\t".$row_Rt2['s13']."\t".$row_Rt2['s14'];
 $str .= "\t".$row_Rt2['sdate']."\t".$row_Rt2['cman']."\t".(($row_Rt2['ck']==1)?"已審":"" )."\t".(($row_Rt2['ck2']==1)?"未審":"")."\t\n";
 }else{
	 
 $str = " \t 攜伴 \t".$row_Rt2['s1']."\t".$row_Rt2['s2']."\t".$row_Rt2['s3']."\t";
 $str .= $row_Rt2['s4']."\t".$row_Rt2['s5']."\t".$row_Rt2['s6']."\t".$row_Rt2['s7']."\t".$row_Rt2['s8']."\t".$row_Rt2['s9']."\t".$row_Rt2['s10']."\t".$row_Rt2['s11']."\t".$row_Rt2['s12']."\t".$row_Rt2['s13']."\t".$row_Rt2['s14'];
 $str .= "\t \t \t".(($row_Rt2['ck']==1)?"已審":"" )."\t".(($row_Rt2['ck2']==1)?"未審":"")."\t\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);
?>
