I am trying to write or find scripts that will:

1- create a script that will allow someone to Unsubscribe to a mailing list based on email address.

2- export data to a predefined excel file which will be used to print mail labels.

I have looked and looked and have found nothing which works properly.

Thank you for any and help.

Vai

do you have a mailing list setup that someone can unsubscribe from. if not, i recommend using www.mailing-manager.com. they will have everything you need.

i have a class to export mysql database to excel file. i have a working example if you need one.

Keith,

If you have the a working example of exporting mysql data to excel I would appreciate that. The mailing list signup works almost flawlessly.... I just need to get the unsubscribe part working.

Thanks bud

catch me on skype sometime tomorrow and I will give you the url and credentials to the site. i would post it here but the example is in one of my administrative centers for a site that hasn't gone live yet and I don't want everyone having access.

also, send me your mailing list script so i can add the unsubscribe part.

If you have the a working example of exporting mysql data to excel I would appreciate that.

A simple example.

<?php
$file="test.xls";
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
?>
commented: Even works for open office, right on! +1

Nav33n,

That works to open an xls file, w/ cell 1- cell2 but what do I need to do to have actual data displayed from the database?

Thanks again

Instead of

$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";

fetch the data from the database and use it.

$text = "Name \t Age \n"; //header
while($row = mysql_fetch_array($result)) {
 $text.=$row['name']."\t".$row['age']."\n"; //records
}
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";

Wow! That really works! I've always done just plain csv files, I didn't know you could use html. You've made my day.

<?php
$file="test.xls";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
?>
<table cellpadding="0" cellspacing="0">
	<tr>
		<td>cell one</td>
		<td>cell two</td>
		<td>cell three</td>
		<td>cell four</td>
	</tr>
	<tr>
		<td colspan="4" align="center"><b>cell one</b></td>
	</tr>
	<tr>
		<td>cell one</td>
		<td>cell two</td>
		<td>cell three</td>
		<td>cell four</td>
	</tr>
</table>

Freaking cool man! Thx.
:) :) :) :) :) :) :) :) :)

You are welcome! ;)

Hi,

I am using the same headers to generate the excel file, which works pretty fine. The problem is tht my org. is migrating to Office 2010, which means using excel 2010. Now, the application generated .xls files, which, when opened in excel 2010, gives a warning message saying something to the tune of "the format is not compatible. verify if the file is correct". If i click on yes, file opens without hassles. How do i make my file compatible to Office 2010?

Please change the extension of .xls file to .xlsx when you export may be this will solve your problem.

Please change the extension of .xls file to .xlsx when you export may be this will solve your problem.

Thanks Ayesha. I had tried that, but it didnt work. I also tried changing the header "Content-type" to "application/vnd.openxmlformats-officedocument.spreadsheetml.shee", which is the standard one for xlsx format. That didnt work as well. However, i found a workaround for it. I changed my headers and used the following:-

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=$filename.xslx");
header("Content-Transfer-Encoding: binary");

and it worked, after i specified to use Excel 2010 as the default program to open this file. However, i still dont understand why changing the content type header did not work. Any pointers anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.