Converting HTML to Excel in php 2011View more random threads:
- PHP include instead of iFrame 2011
- checkbox and mysql in php 2011
- Radio button selection problem in php 2011-12
- php lectures in urdu of Virtual University of Pakistan 2012
- Moving to preg_replace() from eregi_replace() in php 2011
- How to make friends linking process page with php?
- New version of xampp mysql is not working on windows 7 in...
- php&mysql urdu turtorial for Urdu speaking distance...
- Upload Variables not getting passed in php 2011
- Hyperlinking in Php?
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"; ?>
Sponsored Links
There are currently 1 users browsing this thread. (0 members and 1 guests)