المشاركات

عرض الرسائل ذات التصنيف MySQL to CSV

How to Export Data from MySQL Table to CSV File in PHP

صورة
Hi! We'll see in this PHP Tutorial, How to Export Data from MySQL to CSV File in PHP . It's not uncommon to import and export data from database management system. Sometimes you may want to export the data from database into CSV format as the term CSV stands for comma separated value and it's a good human readable format like JSON . PHP 5.1 and above supports the csv formatting function fputcsv() , and combining it with PHP's file handling functions we can very easily convert the mysql table to a csv file. Related Read: How to Import CSV File into MySQL Database using PHP Create Example MySQL Database Table First of all run this sql statement to create mysql table to use as an example for this tutorial. -- Database: `db_books` CREATE TABLE IF NOT EXISTS `tbl_books` ( `id` int(8) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `author` varchar(30) NOT NULL, `isbn` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ...