You can export your MySQL database to .csv file format (Microsoft Excel file) easily using php.
This tutorial require 1 PHP file and 1 table of mySQL database.
1. exportcsv.php
2. The table is with 2 fields: id(auto_increment), name(varchar, 50) and put some records about 20 – 30 records into this table. (directly by phpMyAdmin)
The exportcsv.php file looks like this :-
< ?php
// Connect database
$database="mydb";
$table="mytablename";
mysql_connect("localhost","","");
mysql_select_db("mydb");
$result=mysql_query("select * from $table");
$out = '';
// Get all fields names in table "mytablename" in database "mydb".
$fields = mysql_list_fields(mydb,$table);
// Count the table fields and put the value into $columns.
$columns = mysql_num_fields($fields);
// Put the name of all fields to $out.
for ($i = 0; $i < $columns; $i++) {
$l=mysql_field_name($fields, $i);
$out .= '"'.$l.'",';
}
$out .="\n";
// Add all values in the table to $out.
while ($l = mysql_fetch_array($result)) {
for ($i = 0; $i < $columns; $i++) {
$out .='"'.$l["$i"].'",';
}
$out .="\n";
}
// Open file export.csv.
$f = fopen ('export.csv','w');
// Put all values from $out to export.csv.
fputs($f, $out);
fclose($f);
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename="export.csv"');
readfile('export.csv');
?>
Incoming search terms:
- export mysql to excel using php (139)
- export mysql table to excel using php (44)
- php export mysql to csv (34)
- php mysql export to excel (33)
- php mysql csv export script (25)
- php mysql export csv (23)
- php script to export mysql to csv (23)
- export mysql database to excel using php (22)
- php mysql to csv (22)
- export from mysql to excel php (21)
- export mysql to excel php script (21)
- mysql to csv php (21)
- mysql to excel using php (20)
- php script to export mysql to excel (19)
- how to export mysql table to excel using php (17)
- php mysql export to excel script (17)
- symfony2 csv (17)
- symfony2 export csv (17)
- export mysql to excel (16)
- Excel php mysql (15)
- php export mysql to excel (15)
- php mysql to excel (13)
- export mysql to excel php (12)
- export to excel using php (12)
- export mysql to csv php (11)
- export mysql to excel script (11)
- php export to excel tutorial (11)
- php export excel tutorial (10)
- php mysql csv export (10)
- how to export mysql to excel using php (9)
- mysql export to excel (9)
- mysql to excel php (9)
- symfony2 csv export (9)
- symfony2 export to excel (9)
- export mysql to csv using php (8)
- export mysql using php (8)
- mysql to csv using php (8)
- php mysql excel export (8)
- php mysql excel export script (8)
- php mysql export excel (8)
You will also be interested in ,
- Export MySql database table to pdf using php
- Image gallery using php and mysql blob storage and displaying the image from mysql blob
- Reset all the table values in Mysql
- Find the sum of multiple fields inside a table in mysql
- How to run a SQL query in phpMyAdmin
- Mysql backup via cron using php and email the file
- Display mysql table using for loop in php
- Simple Visitor Counter Using php
- To insert the new column after a specific column using mysql
- Fix Too many connections mysql_connect


thank youuuuuuuuuuuuuuuuuuuu!!