Converting HTML to Excel in php 2011View more random threads:
- Php and Mysql new script of Auto Tweet Script 2011
- The required PHP extension MySQLi could not be found....
- what is factorial language?
- Undifned index upgrade from php4 to php5 2011
- what are the latest updates for Mysql May 2011
- php basic tags to start with
- All php scripts for 2011 online
- Variables in function names in php 2011
- Php Transaction 2011
- waht is mean by lenght of strings" what is its use in...
Sponsored Links
Code:<script type="text/javascript"> <!-- var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() //--> </script> <?php include('ADC_project_excel1.php'); $result = mysql_query("SELECT * FROM NewProject"); $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/vnd.ms-excel; name='excel'"); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=excelfile.xls"); header("Pragma: no-cache"); header("Expires: 0"); echo $header."\n".$data; //print "done"; ?>
There are currently 1 users browsing this thread. (0 members and 1 guests)