|
|
|
ช่วยด้วยครับ มือใหม่ fwrite ออกมาเป็น Excel แต่ หัว Culum มี 22 Culum |
|
|
|
|
|
|
|
<?php
header("Content-Type:text/html; charset=utf-8");
session_start();
error_reporting(0);
include "connect.php";
//$filName = "customer.csv";
//$objWrite = fopen("customer.csv", "w");
$filName = "IEAT_".date('Ymd').".csv";
$objWrite = fopen($filName, "w");
$StartsDate = $_POST["textfield2"];
$EndDate = $_POST["textfield3"];
echo "$StartsDate<br>";
echo "$EndDate<br>";
$strSQL = "SELECT * FROM lx001 where CreationDate >= ' $StartsDate' and CreationDate <= '$EndDate' ";
$objQuery = mysql_db_query($dbname,$strSQL) or die ("Error Query [".$strSQL."]");
//coloum name
fwrite($objWrite, "\"ReferenceNo\",\"EstablishNo\",\"CTN_FactoryOwner \",\" XMLUserID\",\"CreationDate\",\" InvoiceNumber\",\" Arrival/DepartureDate\",\" Company Branch\",\"CreationDate\",");
fwrite($objWrite, "\"CreationDate\" \n");
while($objResult = mysql_fetch_array($objQuery))
{
fwrite($objWrite,"\"$objResult[ReferenceNo]\",\"$objResult[EstablishNo]\",\"$objResult[CTN_FactoryOwner]\",\"$objResult[XMLUserID]\",\"$objResult[CreationDate]\",\"$objResult[InvoiceNumber]\",\"$objResult[Arrival/DepartureDate]\","); (จะทำยังไงไม่ให้ Eorrer อะครับ เหมือนกับว่า ตรงบรรทันนี้มันยาวเกินไปมันเลยไม่ดึงข้อมูลมาให้อะครับ )fwrite($objWrite, "\"$objResult[CreationDate]\" \n");
}
fclose($objWrite);
echo "<br><a href=$filName>Download Report<br><Download</a>";
?>
<META HTTP-EQUIV='REFRESH' CONTENT='0; URL=<?=$filName ?>'>
<META HTTP-EQUIV='REFRESH' CONTENT='0; URL= search_data.php'>
Tag : PHP, MySQL, Excel (Excel.Application)
|
|
|
|
|
|
Date :
2010-12-06 11:51:35 |
By :
sofig |
View :
902 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|