Forum Moderators: coopster
Ihave a query to display all the unique email address from a specific table....
/////////////query////////////////
$url2 = "select distinct(Email) as Email from reservations where Island='$destination' order by Email";
$resulturl2 = mysql_query($url2);
while ($resurl2=mysql_fetch_assoc($resulturl2))
{
$email = $resurl2['Email'];
?>
<strong><? echo $email?></strong> <br>
<?
}
?>
//////////////////////////////
I would like to be able to export the results in an excel file somehow, each email should go to a different row of the spreadsheet.....and if this can be done...where does the excel file is saved?
Plz help me, any comments will be appreciated...
you could also try this
[webmasterworld.com...] msg 9
though coop worked out some header issues with that function, I can't remember where that is though.
>> where does the excel file is saved
that particular bit of code will prompt for save I think
it depends on where you want to save it, as a file on the server or on a local machine. Both options are fairly straight forward.
Export a table to CSV [webmasterworld.com]
<table>
<tr>
<th>email</th>
</tr>
<tr>
<td>one@example.com</td>
</tr>
<tr>
<td>two@example.com</td>
</tr>
</table>
Give the output the extension .xls. MS Excel will open such a file without any conversion prompts.
Send the headers mentioned in the other posts, or try this, which usually works fine for me:
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=somename.xls");
header("Content-length: ". strlen($data));
header("Content-Transfer-Encoding: BINARY");
///////////////////////////////////////////////
$destination = $_REQUEST['destination'];
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=Emails.xls");
header("Content-Transfer-Encoding: BINARY");
include "dbconnect.php";
?>
<table>
<?
$url2 = "select distinct(Email) as Email from reservations where Island='$destination' order by Email";
$resulturl2 = mysql_query($url2);
while ($resurl2=mysql_fetch_assoc($resulturl2))
{
$email = $resurl2['Email'];
?>
<tr>
<? echo $email?>
</tr>
<?
}
?>
</table>
//////////////////////////////////////
thx again