0

I am trying to write a csv file in php, so that when user clicks on an icon, it will generate a csv file using data from my database.

Everything works and I have three columns: name, date, age

I was wondering if in php, I can apply the filter. For example, in excel, I can click on sort & filter -> filter on the first row, which will create a drop down menu with several features.

Is this possible?

Thanks in advance.

2
  • Not from a CSV file. It can be added manually in MS Excel after the CSV file has been opened; or you can create a real Excel file with the filter area pre-defined which will have the selection boxes and sort options available when the end-user opens the file in MS Excel Commented Jan 25, 2013 at 16:46
  • You would have to use a library such at PHPExcel to do that. CSVs are confined to text by nature, the added fancy stuff (sorts, graphs, etc.) is provided through the various spreadsheet applications (Excel, Numbers, OpenOffice, etc.). Commented Jan 25, 2013 at 16:47

1 Answer 1

1

You can sort/filter while extracting from the database, then write the filtered and sorted data into the CSV file.

If you do this by taking inputs from a form on your web page, make sure that you validate the inputs server-side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.