user3773893
user3773893

Reputation: 7

export data into CSV format and store the csv file in the server

how to save a csv file in server itself containing the data fetching form mysql dtatbase? i want to download a database in csv format.I am able to download the contants directly, but I need to save all the fetched data into server itself and provide the user a link to download the data into xls or csv format. I am new to this field and I really don't have any idea how to save the CSV file in server itself.

Upvotes: 0

Views: 585

Answers (3)

Umair Hamid
Umair Hamid

Reputation: 3557

You can write fetched data in a file and then can save this file your server.

There are many php libraries for this job. I Personally use PHPExcel. You can download it from: https://phpexcel.codeplex.com/

Upvotes: 0

Deepak Vn
Deepak Vn

Reputation: 122

You can first query the database with required conditions and write the contents into a CSV file on your application server & later on provide a link to this file in your application. You may check the following link on how to obtain data, convert to CSV & write to file :

PHP code to convert a MySQL query to CSV

Upvotes: 1

turson
turson

Reputation: 421

  1. Create file using CSV separator i.e ;
  2. Create downloading page, you have to set some headers
  3. Download All.

Upvotes: 0

Related Questions