php3-list | 2000051
Date: 05/01/00
- Next message: TV Karthick Kumar: "[PHP3] Testing...."
- Previous message: Antoine Maisonneuve: "[PHP3] Too many open files in system"
- Next in thread: Dave Goodrich: "Re: [PHP3] [Q] Saving content to local machine"
- Reply: Dave Goodrich: "Re: [PHP3] [Q] Saving content to local machine"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have a script that builds a .csv file on the fly and then has a link for the user to click on to download it.
I had to add the .csv file type to APACHE's list of MIME types and then restart apache in order to get a
"SAVE AS" dialogue box when I clicked on the link.
function build_csv($query,$curs,$filename) {
//$query is the text of the SQL query
// $curs is the Oracle Cursor that has been opened outside of the function
// $filename is the name we want to call the new .csv file
//builds a csv file so the user can download it and use a spreadsheet to open it.
//a csv file is really just a comma delimited text file with a row of column names at the top.
$buffer_string = "";
ora_parse($curs, $query)
or die("could not parse request");
ora_exec($curs)
or die("could not execute query");
$ncols = ora_numcols($curs);
for ($i = 0; $i < $ncols; $i++ ) {
$buffer_string .= ora_ColumnName($curs, $i).",";
}
$buffer_string .= "\r";
while (ora_fetch($curs)) {
$i++;
for ($c = 0; $c < $ncols; $c++ ) {
$buffer_string .= ora_getcolumn($curs, $c).",";
//end for
}
$buffer_string .= "\r";
//end while
}
//open a new textfile:
$fp = fopen( "../TEXTFILES/$filename","w+");
//write the string to the file
$write = fwrite($fp,$buffer_string);
//end function:
}
>>> "Donovan J. Edye" <donovan <email protected>> 04/26/00 09:43PM >>>
G'Day All,
I would like to be able to save some database content to a text file on the
client's machine. If I could achieve a SaveAs dialog (or similair) and then
spool the information into the file that would be great. I have a few vague
ideas on how to achieve this, but any help, pointers would be appreciated.
TIA
------------------------------------------------------------------------
--Donovan
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems, Delphi Developer
Web: www.namsys.com.au E-Mail: donovan <email protected>
Voice: +61 2 6285-3460 Fax: +61 2 6285-3459
TVisualBasic = Class(None);
------------------------------------------------------------------------
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: TV Karthick Kumar: "[PHP3] Testing...."
- Previous message: Antoine Maisonneuve: "[PHP3] Too many open files in system"
- Next in thread: Dave Goodrich: "Re: [PHP3] [Q] Saving content to local machine"
- Reply: Dave Goodrich: "Re: [PHP3] [Q] Saving content to local machine"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

