Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Define our Database and Table Info */
- $username="";
- $password="";
- $database="";
- $table="";
- mysql_connect(localhost,$username,$password);
- @mysql_select_db($database) or die( "Unable to select database");
- $select = "SELECT * FROM $table";
- $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/x-msdownload");
- header("Content-Disposition: attachment; filename=mailinglist.xls");
- header("Pragma: no-cache");
- header("Expires: 0");
- print "$headern$data";
- ?>
- <?php
- / Define our Database and Table Info /
- $username="";
- $password="";
- $database="";
- $table="";
- mysql_connect(localhost,$username,$password);
- @mysql_select_db($database) or die( "Unable to select database");
- $select = "SELECT * FROM $table";
- $export = mysql_query($select);
- $fields = mysql_num_fields($export);
- for ($i = 0; $i < $fields; $i++) {
- $header .= mysql_field_name($export, $i) . ",";
- }
- while($row = mysql_fetch_row($export)) {
- $line = '';
- foreach($row as $value) {
- if ((!isset($value)) OR ($value == "")) {
- $value = ",";
- } else {
- $value = str_replace('"', '""', $value);
- $value = '"' . $value . '"' . ",";
- }
- $line .= $value;
- }
- $data .= trim($line)."n";
- }
- $data = str_replace("r","",$data);
- if ($data == "") {
- $data = "n(0) Records Found!n";
- }
- header("Content-type: application/x-msdownload");
- header("Content-Disposition: attachment; filename=mailinglist.xls");
- header("Pragma: no-cache");
- header("Expires: 0");
- print "$headern$data";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement