erp_cool
02-08-2006, 05:48 AM
Hi all,
How can i export a PHP page to Excel.
can anybody help me,
Thks,
erp_cool
How can i export a PHP page to Excel.
can anybody help me,
Thks,
erp_cool
|
Click to See Complete Forum and Search --> : Excel erp_cool 02-08-2006, 05:48 AM Hi all, How can i export a PHP page to Excel. can anybody help me, Thks, erp_cool NogDog 02-08-2006, 07:36 AM Probably your best bet would be to create CSV (comma-separated value) files, which are easily readable by Excel. See http://www.php.net/manual/en/function.fputcsv.php erp_cool 02-08-2006, 11:19 PM hi, Thks for ur reply if i have a single query my export to excel wrks fine My coding is as follows: <?php require_once "include/connect.php"; $prod_name=$_GET[pname]; $select ="SELECT prod_name Product_Name,module_name Module_Name from dt_module where prod_name='$prod_name'"; $export = mysql_query($select); $fields = mysql_num_fields($export); for ($i = 0; $i < $fields; $i++) { $header .= mysql_field_name($export, $i) . "\t"; } 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); if ($data == "") { $data = "\n(0) Records Found!\n"; } header("Content-Type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=".History_.date("d-M-Y").".xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?> But i want to give multiple queries,wht shld i do then? How can i implement this, Thanks in advance erp_cool webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |