473,387 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data Export Grabber

Hi.
I would like to offer the users of my web application the ability to
export data in the csv format. What I have come up with currently is
writing the stream of data into a csv file which people can right click
and download.
The downside of this, however, is that the file stays on the server and
theoretically and anybody could find the URL to the csv file and
download it.

Do you know any better way of doing this? I have found one potential
method, but it only works on firefox:
http://wikka.jsnx.com/GrabCodeHandler

Thanks

Jul 17 '05 #1
1 1913
NC
bi*******@gmail.com wrote:

I would like to offer the users of my web application
the ability to export data in the csv format. What I
have come up with currently is writing the stream of
data into a csv file which people can right click and
download.

The downside of this, however, is that the file stays
on the server and theoretically and anybody could find
the URL to the csv file and download it.

Do you know any better way of doing this?


Yes. Have a PHP script pose as a CSV file. Since you
provided no details as to what kind of data you are
going to be exporting, here's a generic example of
exporting data from MySQL:

$query = 'SELECT * FROM my_table';
$result = mysql_query($query)
or die('Query failed: ' . mysql_error());
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=data.csv');
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$comma = false;
foreach ($line as $field) {
if (is_numeric($field)) {
$output = $field;
} else {
$output = "'" . str_replace("'", "\\'", $field) . "'";
}
if ($comma) {
$output = ',' . $output;
} else {
$comma = true;
}
echo $output;
}
echo "\r\n";
}

Cheers,
NC

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
4
by: Paolo | last post by:
Hello, I am trying to create a procedure to export my Access data to a word template. I would like to export data from two tables to a word file at the same time. My two tables are named CASES...
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
2
by: Mux | last post by:
I am facing the following problem while exporting data to Word. The current implementation is as described below: I have a JSP file which has a link that enables you to export the data to Word....
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
5
by: rubbishemail | last post by:
Hello, can anybody recommend a simple USB or PCI framegrabber with video input that runs under xp and has a python driver available? I just want to get the image into a file, no special...
1
by: Suhas Dhoke | last post by:
Hello Raja. Where is the constructor of the class orkut ?? On Oct 24, 1:40 pm, Raja <RajaSa...@gmail.comwrote:
2
oll3i
by: oll3i | last post by:
my server is complaining about error: Wrapper class grabber.SetLastNameNull is not found. Have you run APT to generate them? when i dont have SetLastNameNull function i have setLastNameNull...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.