How to Export data to CSV file from Database using XAMPP ?
In this article, we are going to load the data present in the database (MySQL) into CSV file. Display the data in the database and also export that data into CSV file. We are using XAMPP tool to store locally in a database.
XAMPP stands for for cross-platform, Apache, MySQL, PHP, and Perl. It is among the simple light-weight local servers for website development.
- Create database and create table in your XAMPP server(MySQL ) database.
- Write PHP Script to access that data
- Verify results
Scenario with CSV: Create two PHP scripts named index.php and export.php Place these files in xampp/htdocs/folder/
index.php: Display the columns along with data using mysqli_fetch_array. The fetch_array() / mysqli_fetch_array() function fetches a result row as an associative array, a numeric array, or both.
1. Open XAMPP Server and start Apache and MySQL server
2. Create database with name “article_geeksdata”
3. Create table inside this database named “geeksdata” and insert data
Open Notepad and type the following code. Save this file as index.php
Output of this web page
Now open another page in notepad and type the following code. Save this file as export.php
Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.