anand.arjunan 0 Posted January 5, 2007 Report Share Posted January 5, 2007 Hi all The php out put file i want generate the excel format please tell me any idea Quote Link to post Share on other sites
rejoice 0 Posted January 5, 2007 Report Share Posted January 5, 2007 Hi all The php out put file i want generate the excel format please tell me any idea<?php if($_REQUEST[zip]==1){ $select = "SELECT order_id,od_date,contact_person,office_name,office_add,menu,zipcode FROM orders where order_date between '".$_REQUEST[acd]."' and '".$_REQUEST[end_acd]."' and type='Rep' order by zipcode"; $export = mysql_query($select); $fields = mysql_num_fields($export);}else{ $select = "SELECT order_id,od_date,contact_person,office_name,office_add,menu,zipcode FROM orders where order_date between '".$_REQUEST[acd]."' and '".$_REQUEST[end_acd]."' and type='Rep'"; $export = mysql_query($select); $fields = mysql_num_fields($export); }?><?php $header = 'Order No'. "\t";$header .= 'Order Date'. "\t";$header .= 'Contact Person'. "\t";$header .= 'Office Name'. "\t";$header .= 'Office Address'. "\t";$header .= 'Menu'. "\t";$header .= 'Zip code'. "\t"; /* for ($i = 0; $i < $fields; $i++) { $header .= mysql_field_name($export, $i) . "\t"; } */?> <?php while($row = mysql_fetch_row($export)) { $line = ''; foreach($row as $value) { if ((!isset($value)) OR ($value == "")) { $value = "\t"; } else { $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); ?> <?php if ($data == "") { $data = "\n(0) Records Found!\n"; } ?><?php header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=Reporders.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?> Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.