|
 |
|
ถามเรื่องการ export file เป็น .csv หน่อยครับ พอดีว่า export file ออกมาได้แล้ว แต่มันมีตัวนี้ติดมาด้วยอะครับ |
|
 |
|
|
 |
 |
|
ของผมทำคล้ายๆแบบนี้ครับ
01.
<?
02.
header('Content-type: application/csv');
03.
header('Content-Disposition: attachment; filename="leave.csv"');
04.
include("../connect.php");
05.
require_once('../connect2.php');
06.
$report_1=$_POST[report_1];
07.
$report_2=$_POST[report_2];
08.
09.
$tbname1="data_round";
10.
$round_id=1;
11.
$sql2="SELECT * FROM $tbname1 where round_id = $round_id";
12.
$result2=mysql_query($sql2, $link);
13.
while($row2 = mysql_fetch_row($result2))$round_1=$row2[1];
14.
15.
echo "รหัสพนักงาน,วันที่ลาหยุด,หยุดถึงวันที่,รวมวันที่หยุด,สาเหตุในการลา,ใบรับรองแพทย์,แผนก,ผู้ยื่นใบลา,ยื่นใบลาวันที่,ผู้อนุมัติใบลา,วันที่อนุมัติใบลา,ผู้ตรวจใบลา,วันที่ตราจใบลา,หมายเหตุ,\n";
16.
$sql = "select * from sick_leave where $report_1 like '%$report_2%' && round=$round_1";
17.
$dbquery = mysql_query($sql);
18.
$num_rows = mysql_num_rows($dbquery);
19.
20.
$i=0;
21.
while ($i < $num_rows)
22.
{
23.
$result= mysql_fetch_array($dbquery);
24.
25.
echo "$result[1],$result[2],$result[3],$result[5],$result[4],$result[10],$result[14],$result[7],$result[6],$result[8],$result[9],$result[11],$result[12],$result[15],\n";
26.
27.
$i++;
28.
}
29.
?>
|
 |
 |
 |
 |
Date :
2011-02-14 17:25:14 |
By :
fourcasia |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|