0

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.

user3773893
  • 7
  • 1
  • 6

3 Answers3

1

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

Community
  • 1
  • 1
Deepak Vn
  • 112
  • 1
  • 11
0
  1. Create file using CSV separator i.e ;
  2. Create downloading page, you have to set some headers
  3. Download All.
turson
  • 421
  • 2
  • 9
0

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/

Umair Hamid
  • 3,509
  • 3
  • 23
  • 25