Dumping Table Data To TXT File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
furiousweebee
Forum Commoner
Posts: 69
Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:

Dumping Table Data To TXT File

Post by furiousweebee »

Here I am again with another novice question. If I have a page of data that is presented using PHP to get the information from MySQL, is there some way to give the user the option to save the results of the query into a TXT file instead of showing it formatted on screen in HTML?

So for example, they use my search facility to find a series of records. Then they want to save that information as a file (without copying and pasting of course). Is there a way to have a link which, when clicked, will use the results of the previous query to save a TXT file?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Just reload the same page again and have an if statment that checks to see if the button was pressed, and if it was print the data to a txt file instead. Search the forums to see how you can get a file to start to download.
furiousweebee
Forum Commoner
Posts: 69
Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:

Post by furiousweebee »

Alrighty, thanks man. I'll look into it. :)
furiousweebee
Forum Commoner
Posts: 69
Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:

Post by furiousweebee »

This solution is slightly off the mark from my original question, but it does exactly what I want it to do. It can save data as Excel or Word files.

http://www.hotscripts.com/Detailed/13890.html
Post Reply