Hi all,
I have code below which save MYSQL to csv file. I am using ADODB
library to do this.
The saving MYSQL to csv file is ok .
However i need to allow the the user to enter file name for csv file.
Anybody have any ideas how to do this? Thanks
$sql = $_SESSION['CSV_SQL'];
$_logger = new Log4jLogger();
$_logger->logdebug('sql:', $sql);
if (!isset($_REQUEST['maintainall'])) {
$filename = 'tbl_chassis.csv';
CSVUtil::UploadTbtoCSV($sql, $filename);
unset($_SESSION['CSV_SQL']);
header('Location: ../maintain.php?csv');
exit;
} else {
//$sql = 'SELECT * from tbl_card';
$filename = 'tbl_card.csv';
CSVUtil::UploadTbtoCSV($sql, $filename);
unset($_SESSION['CSV_SQL']);
header('Location: ../maintainall.php?csv');
exit;
}
function UploadTbtoCSV($sqltext,$filename)
{
$_logger = new Log4jLogger();
$_logger->logdebug("starting.. upload tb to csv");
$rs = dbQuery($sqltext);
$rs->MoveFirst();
$_logger->logdebug("UploadTbtoCSV csvpath:",CSV_PATH);
$fp = fopen(CSV_PATH."/".$filename, "w");
if ($fp) {
rs2csvfile($rs, $fp);
fclose($fp);
$_logger->logdebug("starting upload tb to csv done");
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php