954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Mysql to Excel worksheet, need code

Is it possible to copy a mysql database to an excel worksheet writting PHP code..

please help with code.

rime
Newbie Poster
24 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

Please read my article on exporting to Excel in PHP here .
Let me know if that helps. You can read lot of other articles on that site too.

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

yes I have read your article and its helpful.. thans a lot

rime
Newbie Poster
24 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

ok, Glad I was able to help. You can post your queries in the " Ask an Expert " section also.

binoj_daniel
Practically a Master Poster
645 posts since Dec 2006
Reputation Points: 25
Solved Threads: 18
 

check this code mysql to excel

<?php
ob_start("ob_gzhandler");
include("../config/dbconfig.php");
$result = mysql_query('select * from ra_salesreport');
$count = mysql_num_fields($result);
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
$value = str_replace('', '', $value);
$value = '' . $value . '' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\nno matching records found\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=resume.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>
rahulb310
Newbie Poster
3 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You