<?php $connection=mysql_connect("localhost","root","password") or die("เชื่อมต่อฐานข้อมูลไม่ได้"); mysql_select_db("consensus_mysql") or die("ไม่สามารถเลือกฐานข้อมูลได้"); mysql_query("set character set utf8"); // กำหนดค่า character set ที่จะใช้แสดงผล $sql = "SELECT id, firstname FROM member WHERE status_id =3 ORDER BY id"; $rsItem = mysql_query($sql) or die("Select error1 : ".mysql_error()); $item_id = array(); $item = array(); $i = 0; while($value = mysql_fetch_assoc($rsItem)){ $item_id[$i] = $value['id']; $item[$i] = $value['firstname']; $i ++; } mysql_free_result($rsItem); $sql = "SELECT DISTINCT(tbl_committee.id),project_name, tbl_application.id AS aid, department, tbl_application.regis_id FROM tbl_committee RIGHT JOIN tbl_application ON tbl_application.id = tbl_committee.id ORDER BY tbl_committee.id"; $rsValue = mysql_query($sql) or die("Select error2 : ".mysql_error()); $num_rows = mysql_num_rows($rsValue); if($num_rows>0){ 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=total-score.xls "); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <?php echo'<?mso-application progid="Excel.Sheet"?>';?> <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="<?=$item[$i]?>" ss:ExpandedRowCount="<?=$num_rows+1?>" x:FullColumns="1" x:FullRows="1"> <Row> <Cell><Data ss:Type="String">ลำดับที่</Data></Cell> <Cell><Data ss:Type="String">รหัสเอกสาร</Data></Cell> <Cell><Data ss:Type="String">ชื่อโครงการ</Data></Cell> <Cell><Data ss:Type="String">หน่วยงาน</Data></Cell> <?php for($i=0;$i<count($item_id);$i++){ ?> <Cell><Data ss:Type="String"><?=$item[$i]?></Data></Cell> <?php } ?> </Row> <?php while($ListValue = mysql_fetch_assoc($rsValue)){ ?> <Row> <Cell><Data ss:Type="Number"><?=$rs['id']?></Data></Cell> <Cell><Data ss:Type="String"><?=$rs['regis_id']?></Data></Cell> <Cell><Data ss:Type="String"><?=$rs['project_name']?></Data></Cell> <Cell><Data ss:Type="String"><?=$rs['department']?></Data></Cell> <? for($i=0;$i<count($item_id);$i++){ $sql = "SELECT ret FROM tbl_committee WHERE id={$ListValue['id']} AND user_id={$item_id[$i]}"; $rsColValue = mysql_query($sql) or die("Select error : ".mysql_error()); $ColValue = mysql_fetch_assoc($rsColValue); ?> <Cell><Data ss:Type="Number"><?=number_format($ColValue['ret'])?></Data></Cell> <?php mysql_free_result($rsColValue); }//end for }//end while mysql_free_result($rsValue); ?> </Row> </Table> <? } else{ echo "<p align='center'><strong>ไม่มีข้อมูล</strong></p>"; } ?> <? mysql_close(); ?> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <Selected/> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> </Workbook>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง