I've used this before (not on slimserver though), should hopefully just
be a case of changing the DB name, order by, dbinfo etc.

I got the code from a tutorial, can't find it now though!!


Code:
--------------------
    
  <?php
  
  include ("../includes/dbinfo.php");
  
  // Get database data
  $select = "SELECT * FROM sales ORDER BY Date ASC";
  $export = mysql_query($select);
  $fields = mysql_num_fields($export);
  
  // Extract DB fields
  for ($i = 0; $i < $fields; $i++) {
  $header .= mysql_field_name($export, $i) . "\t";
  }
  
  // Convert into Excel cells
  
  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);
  
  // Check for data
  
  if ($data == "") {
  $data = "\n(0) Records Found!\n";
  }
  
  // Send for download
  
  $date = date("d.m.y");
  $filename = "paypalsales";
  $extension = ".xls";
  $fullfile = $filename . $date . $extension;
  
  header("Content-type: application/x-msdownload");
  header("Content-Disposition: attachment; filename=$fullfile");
  header("Pragma: no-cache");
  header("Expires: 0");
  print "$header\n$data";
  exit;
  echo "Completed";
  ?>
  
--------------------


-- 
audiofi

http://www.audiofi.co.uk/reviews/
------------------------------------------------------------------------
audiofi's Profile: http://forums.slimdevices.com/member.php?userid=726
View this thread: http://forums.slimdevices.com/showthread.php?t=29282

_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/discuss

Reply via email to