|
|
|
สอบถามการส่งออกไฟล์เป็น excel ค่ะ ทำไม มีนส่งออกหมด ทั้งๆที่เราเลือกเดือนเลือกปีแล้ว |
|
|
|
|
|
|
|
พอดีว่ารันบน localhost เป็นปกติค่ะ แต่พอโยนขึ้นserver กลายเป็นพอเลือกเดือนปี ส่งออกไฟล์มันาทั้งหมดค่ะ เลย งง ว่าเป็นเพราะอะไร รบกวนพี่หน่อยค่ะ
หน้าที่เลือก เดือนปี
Code (PHP)
<?php
include("pu_split.php");
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_RepairRS = sprintf("SELECT * FROM tbl_repair ORDER BY id_r DESC");
$RepairRS = mysql_query($query_RepairRS, $schoolsmile) or die(mysql_error());
$row_RepairRS = mysql_fetch_assoc($RepairRS);
$totalRows_RepairRS = mysql_num_rows($RepairRS);
$sql="SELECT * FROM tbl_repair ORDER BY id_r DESC";
$result=pu_query($database_schoolsmile,$sql,30);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_GroupOwnerRS = sprintf("SELECT * FROM tbl_group ORDER BY id_g ASC");
$GroupOwnerRS = mysql_query($query_GroupOwnerRS, $schoolsmile) or die(mysql_error());
$row_GroupOwnerRS = mysql_fetch_assoc($GroupOwnerRS);
$totalRows_GroupOwnerRS = mysql_num_rows($GroupOwnerRS);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_GroupPartRS = sprintf("SELECT * FROM tbl_part ORDER BY id_p ASC");
$GroupPartRS = mysql_query($query_GroupPartRS, $schoolsmile) or die(mysql_error());
$row_GroupPartRS = mysql_fetch_assoc($GroupPartRS);
$totalRows_GroupPartRS = mysql_num_rows($GroupPartRS);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_subGroupRS = sprintf("SELECT * FROM tbl_sub_group ORDER BY id_s ASC");
$subGroupRS = mysql_query($query_subGroupRS, $schoolsmile) or die(mysql_error());
$row_subGroupRS = mysql_fetch_assoc($subGroupRS);
$totalRows_subGroupRS = mysql_num_rows($subGroupRS);
$rob=1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ระบบจัดการเว็บไซต์</title>
<link href="admin/adminstyle.css" rel="stylesheet" type="text/css">
</head>
<table width="1020" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><table width="1020" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#999999">
<tr>
<td height="12" colspan="8" align="center" bordercolor="#FFFFFF" bgcolor="#E4CAAF"><center>
<img src="images/b_search.png" alt="" width="16" height="16" /> <strong><font>ค้นหาเพื่อสร้างรายงานการซ่อมคอมพิวเตอร์</font></strong>
<form method="GET" action="ShowDataReport.php" name="ReportForm" target="_blank">
<label><font>เลือกเดือน
<select name="m_select" id="m_select">
<option value="%">ทั้งหมด</option>
<option value="ม.ค.">มกราคม</option>
<option value="ก.พ.">กุมภาพันธ์</option>
<option value="มี.ค.">มีนาคม</option>
<option value="เม.ย.">เมษายน</option>
<option value="พ.ค.">พฤษภาคม</option>
<option value="มิ.ย.">มิถุนายน</option>
<option value="ก.ค.">กรกฏาคม</option>
<option value="ส.ค.">สิงหาคม</option>
<option value="ก.ย.">กันยายน</option>
<option value="ต.ค.">ตุลาคม</option>
<option value="พ.ย.">พฤศจิกายน</option>
<option value="ธ.ค.">ธันวาคม</option>
</select>
<font>เลือกปี พ.ศ. </label>
<select name="y_select" id="y_select">
<option value="2555">2555</option>
<option value="2556">2556</option>
<option value="2557">2557</option>
</select>
<input type=submit value='รายงานข้อมูล (Excel)' name=submit2 class=BUTTON >
</form>
</center>
<div align="center">
<script language="JavaScript">
function check()
{
var v1 = document.SearchForm.keySearch.value;
if ( v1.length==0)
{
alert("กรุณาป้อนคำที่ค้นหา");
document.SearchForm.keySearch.focus();
return false;
}
else if ( v1=='กรุณาพิมพ์คำค้นที่นี่')
{
alert("กรุณาป้อนคำที่ค้นหา");
return false;
}
else
return true;
}
</script></strong><br /></td>
</tr>
<tr>
<td height="13" colspan="8" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> <img src="images/wait.gif" alt="" width="24" height="21" />= ขั้นตอนดำเนินการ <img src="images/correct.gif" alt="" width="21" height="21" />= ซ่อมเสร็จเรียบร้อย <img src="images/stop.gif" alt="" width="21" height="21" />= ส่งคืน(พัสดุ/ร้านจำหน่าย) </td>
</tr>
<tr>
<td height="10" colspan="8" align="right" bordercolor="#FFFFFF">จำนวนทั้งหมด <?php echo "<font color=#FF0000><b>".$totalRows_RepairRS."</b></font>"; ?> รายการ </td>
</tr>
<tr>
<td width="33" height="25" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ลำดับ</strong></td>
<td width="192" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ชื่อ-สกุลผู้แจ้ง</strong></td>
<td width="138" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>สำนัก/กอง</strong></td>
<td width="121" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>วันที่แจ้งซ่อม</strong></td>
<td width="131" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>อุปกรณ์</strong></td>
<td width="130" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>อาการเสีย</strong></td>
<td width="39" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>สถานะ</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ผลการซ่อม</strong></td>
</tr>
<?php if ($totalRows_RepairRS > 0) { // Show if recordset not empty ?>
<?php do { ?>
<tr >
<td height="1" colspan="8" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><img src="images/px1.gif" width="1" height="1"></td>
</tr>
<tr >
<td bordercolor="#999999" bgcolor="#F5F5F5">
<?php echo $rob++; ?>
<div align="center"></div></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['name']; ?> <?php echo $row_RepairRS['sname']; ?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<?php do {
if (!(strcmp($row_subGroupRS['id_s'], $row_RepairRS['id_s']))) {echo $row_subGroupRS['gsname'];
}
} while ($row_subGroupRS = mysql_fetch_assoc($subGroupRS));
$rows = mysql_num_rows($subGroupRS);
if($rows > 0) {
mysql_data_seek($subGroupRS, 0);
$row_subGroupRS = mysql_fetch_assoc($subGroupRS);
}
?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['date_in']; ?></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<?php do {
if (!(strcmp($row_GroupPartRS['id_p'], $row_RepairRS['id_p']))) {echo $row_GroupPartRS['pname'];
}
} while ($row_GroupPartRS = mysql_fetch_assoc($GroupPartRS));
$rows = mysql_num_rows($GroupPartRS);
if($rows > 0) {
mysql_data_seek($GroupPartRS, 0);
$row_GroupPartRS = mysql_fetch_assoc($GroupPartRS);
}
?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['ofservice']; ?></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<center><?php if ($row_RepairRS['r_status']=='' or $row_RepairRS['r_status']=='WAIT') {echo "<img src=images/wait.gif>";} else if ($row_RepairRS['r_status']=='OK') {echo "<img src=images/correct.gif>";} else {echo "<img src=images/stop.gif>";} ?></center></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['r_summari']; ?> </td>
</tr>
<?php } while ($row_RepairRS = mysql_fetch_assoc($RepairRS)); ?>
<?php } // Show if recordset not empty ?>
</table>
<table align="right"><tr><td>
<? pu_pageloop("category=$category&rob=$rob"); ?>
</td></tr></table>
</td>
</tr>
</table>
ไฟล์excelCode (PHP)
<?
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=DataRepair.xls");
?>
<?php
require_once('Connections/docconnection.php');
//require_once('function.php');
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_RepairRS = "SELECT * FROM tbl_repair where date_in LIKE '%$m_select $y_select%' ORDER BY id_r, id_g, id_s, date_in DESC";
$RepairRS = mysql_query($query_RepairRS, $schoolsmile) or die(mysql_error());
$row_RepairRS = mysql_fetch_assoc($RepairRS);
$totalRows_RepairRS = mysql_num_rows($RepairRS);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_GroupOwnerRS = sprintf("SELECT * FROM tbl_group ORDER BY id_g ASC");
$GroupOwnerRS = mysql_query($query_GroupOwnerRS, $schoolsmile) or die(mysql_error());
$row_GroupOwnerRS = mysql_fetch_assoc($GroupOwnerRS);
$totalRows_GroupOwnerRS = mysql_num_rows($GroupOwnerRS);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_GroupPartRS = sprintf("SELECT * FROM tbl_part ORDER BY id_p ASC");
$GroupPartRS = mysql_query($query_GroupPartRS, $schoolsmile) or die(mysql_error());
$row_GroupPartRS = mysql_fetch_assoc($GroupPartRS);
$totalRows_GroupPartRS = mysql_num_rows($GroupPartRS);
mysql_select_db($database_schoolsmile, $schoolsmile);
$query_subGroupRS = sprintf("SELECT * FROM tbl_sub_group ORDER BY id_s ASC");
$subGroupRS = mysql_query($query_subGroupRS, $schoolsmile) or die(mysql_error());
$row_subGroupRS = mysql_fetch_assoc($subGroupRS);
$totalRows_subGroupRS = mysql_num_rows($subGroupRS);
$rob=1;
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ระบบจัดการเว็บไซต์</title>
</head>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><table width="1077" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#999999">
<tr>
<td colspan="8" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td colspan="8" align="center" bordercolor="#FFFFFF" bgcolor="#E4CAAF"><strong>แสดงข้อมูลรายการแจ้งซ่อมคอมพิวเตอร์ </strong></td>
</tr>
<tr>
<td height="25" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ลำดับ</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ชื่อ-สกุลผู้แจ้ง</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>สำนัก/กอง</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>วันที่แจ้งซ่อม</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>อุปกรณ์</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>อาการเสีย</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>สถานะ</strong></td>
<td align="center" bordercolor="#999999" bgcolor="#CCCCCC"><strong>ผลการซ่อม</strong></td>
</tr>
<?php if ($totalRows_RepairRS > 0) { // Show if recordset not empty ?>
<?php do { ?>
<tr >
<td height="1" colspan="8" align="center" bordercolor="#999999" bgcolor="#CCCCCC"><img src="images/px1.gif" width="1" height="1"></td>
</tr>
<tr >
<td bordercolor="#999999" bgcolor="#F5F5F5"> <?php echo $rob; $rob++; ?></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['name']; ?> <?php echo $row_RepairRS['sname']; ?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<?php do {
if (!(strcmp($row_subGroupRS['id_s'], $row_RepairRS['id_s']))) {echo $row_subGroupRS['gsname'];
}
} while ($row_subGroupRS = mysql_fetch_assoc($subGroupRS));
$rows = mysql_num_rows($subGroupRS);
if($rows > 0) {
mysql_data_seek($subGroupRS, 0);
$row_subGroupRS = mysql_fetch_assoc($subGroupRS);
}
?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['date_in']; ?></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<?php do {
if (!(strcmp($row_GroupPartRS['id_p'], $row_RepairRS['id_p']))) {echo $row_GroupPartRS['pname'];
}
} while ($row_GroupPartRS = mysql_fetch_assoc($GroupPartRS));
$rows = mysql_num_rows($GroupPartRS);
if($rows > 0) {
mysql_data_seek($GroupPartRS, 0);
$row_GroupPartRS = mysql_fetch_assoc($GroupPartRS);
}
?> </td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['ofservice']; ?></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5">
<center><?php if ($row_RepairRS['r_status']=='' or $row_RepairRS['r_status']=='WAIT') {echo "รอดำเนินการ";} else if ($row_RepairRS['r_status']=='OK') {echo "ซ่อมเสร็จแล้ว";} else {echo "ซ่อมไม่ได้(ส่งคืน)";} ?></center></td>
<td align="left" bordercolor="#999999" bgcolor="#F5F5F5"><?php echo $row_RepairRS['r_summari']; ?> </td>
</tr>
<?php } while ($row_RepairRS = mysql_fetch_assoc($RepairRS)); ?>
<?php } // Show if recordset not empty ?>
</table>
</td>
</tr>
</table>
Tag : PHP, MySQL, Excel (Excel.Application)
|
|
|
|
|
|
Date :
2013-12-02 10:23:24 |
By :
NToo |
View :
676 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ว๊าาา ไม่มีใครช่วยเลยหรือค่ะ
|
|
|
|
|
Date :
2013-12-02 14:11:09 |
By :
NToo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอเดาว่าเซิร์ฟเวอร์ไม่ซัพพอร์ท Global variable ครับ
%$m_select $y_select%
ต้องเปลี่ยนเป็นแบบนี้ครับ
%{$_GET["m_select"]} {$_GET["y_select"]}%
|
|
|
|
|
Date :
2013-12-02 18:19:41 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|