I'm using php/mysql for a website. One page the user can create a query to pull data from the database, but I want it to automatically save the data to a csv file. Is this possible, and how?
It certainly is possible:
[tt]
SELECT fieldlist
INTO OUTFILE 'filepath'
FROM ...
WHERE ...
[/tt]
This will output to a file using tab delimiters. If you want to use the traditional CSV delimiters of quotes and commas, you can use:[tt]
INTO OUTFILE 'filepath'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.