473,396 Members | 1,852 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,396 software developers and data experts.

Export Table to .csv (tab delimited)

Hi, i was wondering if anyone could help me export a table that i have created to a tab delimited csv file...

Code example of my Query and print:
[PHP]mysql_connect($server, $db_user, $db_pass)
or die ("Database CONNECT Error");

$result = mysql_db_query($database, "SELECT sum(payment) as payments, email, sales.refid FROM sales,affiliates WHERE sales.refid=affiliates.refid group by email")
or die ("Database Error");

if (mysql_num_rows($result))
{

print "<font face=arial><TABLE border=1 cellspacing=0 cellpadding=3 align=center>";
print "<TR><TH>PayPal Account</TH><TH>Payment</TH><TH>Type</TH>";
print "<TH>Referrer</TH>";
print "<TH>Message</TH></TR>";

while($info = mysql_fetch_array( $result ))
{

print "<TR>";
print "<TD><font size=2>";
print $info['email'];
print "</TD>";

print "<TD><font size=2>";
print $info['payments'];
print "</TD>";
print "<TD><font size=2>";
print "AUD";
print "</TD>";
print "<TD><font size=2>";
print $info['refid'];
print "</TD>";
print "<TD><font size=2>";
print "VicPay Commission Statement";
print "</TD>";
print "</TR>";
}
print "</table>";
} [/PHP]

Now that i have displayed the table correctly in PHP i have no idea how to export it...
is there a way i can have save button or hyperlink to download the file??

thanks
FallingReign
Mar 9 '07 #1
4 7386
Also here is how my tables look in the SQL DB

Database

-Affiliates (table)
--refid
--email
--name
--surename
--etc..

-Sales (table)
--refid
--payment
--type
--etc...
Mar 9 '07 #2
ronverdonk
4,258 Expert 4TB
What version of PHP are you using? If 5.1 or > you can use the fputcsv command. See manual at FPUTCSV

Ronald :cool:
Mar 9 '07 #3
What version of PHP are you using? If 5.1 or > you can use the fputcsv command. See manual at FPUTCSV

Ronald :cool:
Im using Dreamweaver MX 2004 so im not sure what version of PHP that is but that function isn't supported...
Mar 9 '07 #4
ronverdonk
4,258 Expert 4TB
Have a look at the IAM CSV Dump class of phpclasses.org. What it does:

This class takes the results of a SQL query and outputs in the CSV (comma separated values) format.

The class offers the choice of sending the output to the browser or downloading it as a file. The name and extension of the dump file are defined by the developer.
Ronald :cool:
Mar 10 '07 #5

Sign in to post your reply or Sign up for a free account.

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...
1
by: frankvfox | last post by:
I need a code sample using VB ASP.Net 2003 which exports a tab delimited text file resident on the server into an Excel spreadsheet which will be saved through the browser to the client's local...
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...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
5
by: RadhakrishnanR | last post by:
Hi, By using VB6.0, I want to export database table data into (i.e based on the selected file type(xls or txt)) excel file or text file with a tab delimited text file. My User interface has: ...
2
by: RadhakrishnanR | last post by:
Hi, By using VB6.0, I want to export database table data into text file with a tab delimiter. My User interface has: • Drop down list box contain list of data base table name. • A path...
1
by: ZBV | last post by:
I have a date/time field which only contains the date. When I export the table to a tab-delimited file, the text file always contains not only the date but also the time (something like 09/22/20007...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
1
by: trinismooth | last post by:
I have a table, from which I created a cross tab query. I need to export the crosstab query so I created a export specification selecting the following options, Tab Delimited, Include filed names on...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.