<?php
// Connection
$conn=mysql_connect('localhost','root','');
$db=mysql_select_db('excel',$conn);
$filename = "fileName.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$user_query = mysql_query('select name,work from info');
// Write data to file
$flag = false;
while ($row = mysql_fetch_assoc($user_query)) {
if (!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
echo implode("\t", array_values($row)) . "\r\n";
}
?>
Do feel free to ask any questions that you may have concerns to web. No Compromise on Learning!
Wednesday, November 4, 2015
Export MySQL data to Excel in PHP
Subscribe to:
Post Comments (Atom)
How to change the PHP version for subfolders or subdomains
How to change the PHP version for subfolders or subdomains Setting a specific PHP version for a specific websites, subfolders or subdomain...
-
What is PHPSpreadSheet Library PHPSpreadSheet library is purely writter in PHP and it main purpose of communicate your PHP application with ...
-
Select2 is a jQuery plugin that extends the functionality of a simple HTML drop-down element by allowing to search the list, adding the ima...
-
I would make a function that checks every selected value, and then enables all option s, searches through the .staff_list s for option s ...
No comments:
Post a Comment
Please Comment Here!