| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/news/elearning/ |
Upload File : |
<?
$idsubject=$_GET["idsubject"];
require './configs/host.php';
mysql_query( "SET NAMES utf8");
$ql="SELECT
`exp_users`.`user_email`,
`exp_users`.`user_fullname`,
`exp_users`.`user_class`,
`exp_test_results`.`tr_correct_answer`,
`exp_test_results`.`tr_exam_date`,
`exp_test_results`.`tr_total_question`
FROM
`exp_test_results`
INNER JOIN `exp_users`
ON `exp_users`.`user_id` = `exp_test_results`.`tr_user_id` where tr_subject_id='$idsubject' ";
$qr=mysql_query($ql);
$row_num=mysql_num_rows($qr);
$col_arr=array("เลขประจำตัว","ชื่อ-สกุล","ชั้น","คะแนนเต็ม","สอบได้","ร้อยละ","เวลาสอบ");
$col_num=count($col_arr);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=score.xls ");
?>
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php echo'<?mso-application progid="Excel.Sheet" encoding="UTF-8"?>';?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font x:CharSet="222"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="ผลการสอบ">
<Table ss:ExpandedColumnCount="<?=$col_num?>" ss:ExpandedRowCount="<?=$row_num+1?>" x:FullColumns="1"
x:FullRows="1">
<Row>
<?php foreach($col_arr as $key=>$value){ ?>
<Cell><Data ss:Type="String"><?=$value?></Data></Cell>
<?php } ?>
</Row>
<?php
while($rs=mysql_fetch_array($qr)){
?>
<Row>
<Cell><Data ss:Type="String"><?=$rs['user_email']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['user_fullname']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['user_class']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['tr_total_question']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['tr_correct_answer']?></Data></Cell>
<Cell><Data ss:Type="String"><?php $k = 0; if ($rs["tr_correct_answer"] != 0) { $k = ($rs["tr_correct_answer"]/$rs["tr_total_question"]) * 100;} echo $k = number_format($k, 2); ?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['tr_exam_date']?></Data></Cell>
</Row>
<?php } ?>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>