-2
작동 I 다음 스크립트를했습니다 :PHP를 생성 csv 파일은 처음
<?php
//Define basepath for codeigniter
define('BASEPATH', '/');
//Include constants.php config file from codeigniter
require_once "../../my_manager/system/application/config/constants.php";
//Check username and password from GET
if($_GET['username'] != IMPORT_USERNAME || $_GET['password'] != IMPORT_PASSWORD)
{
header('HTTP/1.0 401 Unauthorized');
echo "Denied Access";
return;
}
//running scripts
include 'export_table1.php';
include 'export_table2.php';
include 'export_table3.php';
include 'export_table4.php';
?>
Eache 수출은 다음과 같다 : 문제는 첫 번째 스크립트가 실행되는 것을
<?php
//$host="localhost";
$host="";
$user="";
$pass="";
$db_name="";
$table="table1";
$conn = mysqli_connect($host,$user,$pass,$db_name) or die("Connection Error");
$query = "SELECT * FROM $table ORDER BY ID";
$result = mysqli_query($conn,$query) or die("sql error");
if(mysqli_num_rows($result)>0)
{
$csv = "";
$row = mysqli_fetch_assoc($result);
$delim = "";
//retrieving first line fields
foreach($row as $k => $v)
{
$csv .= $delim . '"' . str_replace('"', '""', $k) . '"';
$delim= ";";
}
$csv .= "\n";
//retrieving value into fields
while($row = mysqli_fetch_assoc($result))
{
$delim = "";
foreach($row as $v)
{
$csv .= $delim . '"' . str_replace('"', '""', $v) . '"';
$delim = ";";
}
$csv .= "\n";
}
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=".$table.".csv");
echo $csv;
exit
}
else
{
echo "No records";
}
exit
?>
, 그래서 나는 csv 파일로 다운로드 된 첫 번째 테이블 만 얻을 수 있습니다. 먼저 table2 내보내기를 시작하면 table2 내보내기 만 시작됩니다. 어떻게 관리 할 수 있습니까? 미리 감사드립니다!
내보내기 스크립트가 끝날 때 '종료'됩니다 ...!? 또한 하나의 응답으로 여러 개의 CSV 파일을 출력 할 수 없으며 모두 하나의 단일 파일이됩니다. – deceze