|
|
|
ช่วยด้วย !! ผมอยากจะส่งข้อมูลไปเป็นไฟล์ Excel อ่ะครับ ค่าไม่ออกตามหน้าส่ง อ่ะครับ Y,Y |
|
|
|
|
|
|
|
หน้าส่ง
Code (PHP)
<?php
extract($_POST);extract($_GET);extract($_REQUEST);
include_once ("../../config/config.php");
require_once("$CFG->dirClass/clsperiod.php");
require_once("$CFG->dirClass/clsstudentregister.php");
require_once("$CFG->dirClass/clsmajor.php");
require_once("$CFG->dirClass/clsstatus.php");
require_once("$CFG->dirPhp/phpfunction.php");
require_once("$CFG->dirClass/clsReport.php");
$oC = new Connection();
$oP = new period($oC->c);
$oP2 = new period($oC->c);
$obj = new studentregister($oC->c);
$obj2 = new major($oC->c);
$obj3 = new status($oC->c);
$obj4 = new Report($oC->c);
$oM = new major($oC->c);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><?php echo $SYSTEM->name; ?></title>
<link rel="stylesheet" href="<?php echo $CFG->wwwCss;?>/style.css" type="text/css" charset="utf-8" />
<script type="text/javascript" src="<?php echo $CFG->wwwJs;?>/script.js"></script>
<script language="javascript">
function chkFormSearch () {
var frm=document.form2;
var retval = false;
if (chkSQL_Injection(frm.PERIODID.value, 0, "ปี/ภาคการศึกษา") == false) {
frm.PERIODID.focus();
}else {
retval = true;
}
return retval;
} // end function
</script>
</head>
<body>
<div id="wrapper">
<?php require("header.php"); ?> <!-- end header -->
<!-- content -->
<!-- content -->
<div id="content">
<?php require("left.php"); ?>
<!-- end left -->
<!-- start right -->
<div id="right">
<div id="content_right">
<h2>ผลสหกิจศึกษา</h2>
<?php
if (!empty($transaction)) {
echo "<div align=\"center\"><span class=\"highlight\"> ".$transaction." </span></div><br>";
} // end if
?>
<form name="form1" method="post" action="uiReportStudent.php" onSubmit="return chkFormSearch();">
<table width="100%" border="0" cellspacing="1" cellpadding="1" class="tableinput">
<tr>
<th style="width:200px">ค้นหาปี/ภาคการศึกษา</th>
<td class="tdmiddle"> </td>
<td><select name="PERIODID" id="PERIODID">
<option value="">- โปรดเลือก -</option>
<?php
$oP->RSperiod(); // set query
while ($oP->GetRecord()) {
$op = "";
if($oP->PERIODID==$PERIODID)
$op = "selected";
else
$op = "";
?>
<option value="<?php echo $oP->PERIODID; ?>" <?php echo $op; ?>><?php echo $oP->ACADYEAR."/".$oP->SEMESTER; ?></option>
<?php } ?>
</select> <span class="help">*</span></td>
</tr>
<tr>
<th style="width:200px">ค้นหาสาขาวิชา</th>
<td class="tdmiddle"> </td>
<td><select name="MAJORID" id="MAJORID">
<option value="">-โปรดเลือก-</option>
<?php
$cond = "1=1 ORDER BY MAJORNAMETH ASC";
$oM->RSmajor($cond); // set query
while ($oM->GetRecord()) {
if($oM->MAJORID == $MAJORID) {
echo "<option value=\"$oM->MAJORID\" selected>$oM->MAJORNAMETH</option>";
} else {
echo "<option value=\"$oM->MAJORID\">$oM->MAJORNAMETH</option>";
}
}
?>
</select></td>
</tr>
<tr>
<th> </th>
<td> </td>
<td> </td>
</tr>
<tr>
<th> </th>
<td> </td>
<td><input type="submit" name="button" id="button" value="ค้นหา" class="button" />
<span class="submission">
<input name="Submit2" type="button" onclick="location.href='uiReportStudent.php'" value="ยกเลิก" class="button" />
<input name="search" type="hidden" id="search" value="1" />
</span></td>
</tr>
</table>
</form>
<?php
if($search=='1'){
$cond = "studentregister.STATUSID NOT IN (10,13)";
if($PERIODID!=""){
$cond = $cond." AND studentregister.PERIODID = $PERIODID";
}
if($MAJORID!=""){
$cond = $cond." AND studentregister.MAJORID = $MAJORID";
}
$cond = $cond." ORDER BY studentregister.PERIODID, STUDENTCODE, studentregister.GRADE";
$obj->RSstudentregister3($cond);
$nRows = $obj->numRows;
?>
<form name="form2" method="post" action="printReportStudentXls.php" onSubmit="return chkFormSearch();">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right"><a href="<?php echo $CFG->wwwAdmin; ?>/printReportStudentXls.php? $PERIODID=<?php echo $oP->ACADYEAR."/".$oP->SEMESTER; ?> $STUREGID=<?php echo $obj->STUREGID; ?>&STUREGNAMETH=<?php echo $obj->STUREGNAMETH; ?>&MAJORID=<?php echo $obj2->MAJORID; ?>">ส่งออกเป็นไฟล์ Excel</a></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="1" class="tabledata">
<tr>
<th style="width:50px"><center>ลำดับ</center></th>
<th style="width:120px"><center>รหัสนักศึกษา</center></th>
<th><center>ชื่อ - สกุล</center></th>
<th style="width:180px"><center>สาขาวิชา</center></th>
<th style="width:100px"><center>ผลสหกิจศึกษา</center></th>
</tr>
<?php
if ($nRows > 0) {
$numline = 0;
$period = '';
while($obj->GetRecord()) {
$numline++;
$oP2->SearchByKey($obj->PERIODID); // set query
$oP2->GetRecord();
$obj2->SearchByKey($obj->MAJORID);
$obj2->GetRecord();
if($period != $obj->PERIODID){
?>
<tr>
<td colspan="6" align="left" class="rowhead">ปี/ภาคการศึกษา <?php echo $oP2->ACADYEAR."/".$oP2->SEMESTER; ?></td>
</tr>
<?php } ?>
<tr>
<td align="center"><?php echo $numline; ?></td>
<td align="center"><?php echo $obj->STUDENTCODE; ?><span class="nodata">
<input name="STUREGID[]" type="hidden" id="STUREGID[]" value="<?php echo $obj->STUREGID; ?>" />
</span></td>
<td align="center"><?php echo $obj->STUREGNAMETH; ?></td>
<td align="center"><?php echo $obj2->MAJORNAMETH; ?></td>
<td align="center"><?php
if($obj->GRADE=="S"){
echo "<font color='#00CC00'>ผ่าน</font>";
}else if($obj->GRADE=="U"){
echo "<font color='#FF0000'>ไม่ผ่าน</font>";
}else{
echo "ยังไม่ประกาศผล";
}
?></td>
</tr>
<?php
$period = $obj->PERIODID;
}//end while
?>
<tr>
<td colspan="6" align="center" class="nodata">
<input name="method" type="hidden" id="method" value="result" />
<input name="PERIODID" type="hidden" id="PERIODID" value="<?php echo $PERIODID; ?>" />
<input name="MAJORID" type="hidden" id="MAJORID" value="<?php echo $MAJORID; ?>" />
<input name="search" type="hidden" id="search" value="<?php echo $search; ?>" /></td>
</tr>
<?php
}else{
?>
<tr>
<td colspan="6" align="center" class="nodata"><?php echo $DEFINE->nodata; ?></td>
</tr>
<?php } ?>
</table>
</form>
<?php } ?>
</div>
<!-- end right -->
</div>
<!-- end content -->
<div class="clear">
<?php require("footer.php"); ?>
</div>
</body>
</html>
<?php
$oC->Disconnect();
?>
หน้ารับ
Code (PHP)
<?php
header('Content-type: application/xls');
header('Content-Disposition: attachment; filename="ReportStudent.xls"');
extract($_POST);extract($_GET);extract($_REQUEST);
include_once ("../../config/config.php");
require_once("$CFG->dirClass/clsperiod.php");
require_once("$CFG->dirClass/clsstudentregister.php");
require_once("$CFG->dirClass/clscompanyregister.php");
require_once("$CFG->dirClass/clscompany.php");
require_once("$CFG->dirPhp/phpfunction.php");
require_once("$CFG->dirClass/clsmajor.php");
require_once("$CFG->dirClass/clsstatus.php");
$oC = new Connection();
$oP = new period($oC->c);
$oP2 = new period($oC->c);
$obj = new studentregister($oC->c);
$obj2 = new major($oC->c);
$obj3 = new status($oC->c);
$oM = new major($oC->c);
?>
<td>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<?php
$cond = "studentregister.STATUSID NOT IN (10,13)";
if($PERIODID!=""){
$cond = $cond." AND studentregister.PERIODID = $PERIODID";
}
if($MAJORID!=""){
$cond = $cond." AND studentregister.MAJORID = $MAJORID";
}
$cond = $cond." ORDER BY studentregister.PERIODID, STUDENTCODE";
$obj->RSstudentregister3($cond);
$nRows = $obj->numRows;
?>
<tr>
<td colspan="6" align="left" class="rowhead">ปี/ภาคการศึกษา <?php echo $oP->ACADYEAR."/".$oP->SEMESTER; ?></td>
</tr>
<table width="100%" border="1" cellspacing="1" cellpadding="1" class="tabledata">
<tr>
<th width="67" style="width:50px"><center>ลำดับ</center></th>
<th width="158" style="width:120px"><center>รหัสนักศึกษา</center></th>
<th width="231"><center>ชื่อ - สกุล</center></th>
<th width="188" style="width:180px"><center>สาขาวิชา</center></th>
<th width="141" style="width:100px"><center>ผลสหกิจศึกษา</center></th>
</tr>
<?php
if ($nRows > 0) {
$numline = 0;
while($obj->GetRecord()) {
$numline++;
$oP2->SearchByKey($obj->PERIODID); // set query
$oP2->GetRecord();
$obj2->SearchByKey($obj->MAJORID);
$obj2->GetRecord();
if($period != $obj->PERIODID){
?><?php } ?>
<tr>
<td align="center"><?php echo $numline; ?></td>
<td align="center">'<?php echo $obj->STUDENTCODE; ?><span class="nodata">
<input name="STUREGID[]" type="hidden" id="STUREGID[]" value="<?php echo $obj->STUREGID; ?>" />
</span></td>
<td align="left"><?php echo $obj->STUREGNAMETH; ?></td>
<td align="center"><?php echo $obj2->MAJORNAMETH; ?></td>
<td align="center"><?php
if($obj->GRADE=="S"){
echo "<font color='#00CC00'>ผ่าน</font>";
}else if($obj->GRADE=="U"){
echo "<font color='#FF0000'>ไม่ผ่าน</font>";
}else{
echo "ยังไม่ประกาศผล";
}
?></td>
</tr>
<?php
}//end while
}else{
?>
<?php } ?>
<tr>
<td colspan="5" align="center" class="nodata"><?php if ($obj->numRows = 0)
{ echo $DEFINE->nodata;} ?></td>
</tr>
</table>
<?php
$oC->Disconnect();
?>
คือตอนนี้โค้ด หน้าส่ง เอ้าพุตออกตามต้องการ ... แต่หน้ารับ ... ส่งออกไปเป็น Excel ข้อมูลที่เซิสเจอ มันถูกส่งออกหมดเลย ...
ขอความช่วยเหลือหน่อยครับ :'(
Tag : PHP, MySQL, HTML/CSS, Excel (Excel.Application), Windows
|
|
|
|
|
|
Date :
2013-05-23 18:07:06 |
By :
mungkornza |
View :
861 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดู PHPExcel แล้วหรือยังครับ
สร้าง Excel (xls,xlsx) ไฟล์ด้วย PHPExcel และการส่งออก Export จากฐานข้อมูล MySQL Database
|
|
|
|
|
Date :
2013-05-24 09:53:59 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|