Skip to content
Advertisement

Export and download my php table data to csv

I’m trying to get my datbase fetched data to Excel file for downloading it in execl or csv, but I’m having problems with exporting and also No datas are fetching to the csv .Here is my code:

This is my php code

JavaScript

this is my html

JavaScript

this is my export.php page

JavaScript

I need to view these datas on my webpage and also i need to export and download it.

Advertisement

Answer

Here you go!

change

JavaScript

to

JavaScript

and it should work, you can’t use “PDO” with mysqli_query because both are different ways to connect to the database.

You can read more about PDO and mysqli here ->

https://websitebeaver.com/php-pdo-vs-mysqli

You should also enable error reporting. because when I tested the PHP codes it returned an errror.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement