<?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...
 
- 
Welcome to the next part of OpenLayers 3 for Beginners! If you have not worked through parts one or two yet, you can hop over to them he...
- 
Welcome to OpenLayers 3 for Beginners: Part 2. If you have not been to and completed OpenLayers 3 Part 1 yet, head over to http://chris...
- 
Changing the Domainname: Yes, there is some form of "Search and Replace". To update WordPress options with the new blog locat...
 
 
No comments:
Post a Comment
Please Comment Here!