Is it possible to copy a mysql database to an excel worksheet writting PHP code..
please help with code.
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.
yes I have read your article and its helpful.. thans a lot
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;
?>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.