Reply to Re: Mail Fields To Database. Exportable...any ideas?

Your name:

Reply:


Posted by Truck Estevez on 05/23/07 23:13

I actually meant it solely for the client and no one else... moving on
though, I did find an export to excel script but i'm having one
problem: the php displays all the data fine in text form, but a file
download prompt is also supposed to pop up and this isn't happening.
Any ideas why?

Here's the code:


<?php

$user="user";
$host="localhost";
$password="pass";
$database = "db";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
if ($db = mysql_select_db($database,$connection))
echo"connection successful";

if (check_valid_user_admin())
{

$select = "SELECT * FROM mailinglist";
$export = mysql_query($select);
$fields = mysql_num_fields($export);

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("\are","",$data);

if ($data == "") {
$data = "\n(0) Records Found!\n";
}

header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=dorado.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
?>

Like I said, it displays the data fine, just no download prompt which
is a bummer. Any ideas?

Truck

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация