| saving results to a file |
Thu, 18 March 2004 11:07  |
thozi Messages: 36 Registered: February 2004 |
Member |
 From: 175.132.3
|
|
It seems that this forum is never been used. Well I start with it. I'm a newbie in Web programming and I have a very simple task but don't know how to code that.
I want to add a "Save As" button on my Web page form, which either allows the user to enter a filename or using a file browser to select a file and location.
Actually, just the same mechanism you get when you right-click on a hyperlink and select save as.
How could I do that either by displaying a hyperlink or adding a button.
Related to PHL, I want to be able to save the datalist results into a CSV file. And I will use the adodb methods available. I can get the query results in a file without a problem, but I now would like to be able to specify the filename.
The following code fragment shows the way to do it with a fix file name:
// First let's get the mysql query and save it in $query_noLIMIT
$adodblist->data_prefetch();
$query_noLIMIT = $adodblist->_datasource->build_query();
// Now execute the query using ADODB CacheExecute or Execute
$rs = $cpd->CacheExecute($query_noLIMIT);
$path = "C:/test.csv";
// open the file
$fp = fopen($path, "w");
// call ADODBs write to csvfile method.
if ($fp) { rs2csvfile($rs, $fp);
fclose($fp);}
|
|
|
| Re: saving results to a file |
Fri, 19 March 2004 09:58  |
|
|
As for your first question, I'm not really sure, other then having the saveas button submit the form, then having the php script output the file in the format you want and then setting the content type in the header to something that will force the browser to try and save it to disk.
|
|
|