Forum Moderators: coopster

Message Too Old, No Replies

PHP to create a list of emails

How to create a comma seperated list of contact info?

         

madmatt69

8:28 am on Apr 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone,

I'm pretty new to php, and I've got a client asking if there's a way I can create a database with the contact details of their clients, and then download the list and import it into Outlook.

Basically, ths user fills out a form on the website and then that information would be stored in a mySQL database- No prob there. But what I'm wondering is how you would then take that information and write a comma seperated value list (unless there's a better way?) and then have that able to import into Outlook.

So is it possible then to use PHP to write such a file, and if so does anyone know of a tutorial or perhaps a pre-written script that would allow me to do this?

Thanks for any tips and suggestions!

Cheers,

Matt..

dmorison

8:50 am on Apr 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Matt,

Do a Google Groups search on "PHP content-type CSV". This returns plenty of threads on this subject.

The long and the short of it is that a PHP script does not have to return text/html - it can return any content-type you wish - including text/csv - by using the header() function.

You then use standard PHP code to create the output, ala:

echo("field1,field2,field3\n") etc...

Also covered are ways to force the browser to offer the "Save to disk" dialog rather than try to execute it. If you don't, somebody clicking on the link on a Windows machine will probably have the CSV file unceremoniously opened into Microsoft Excel without asking!

Cheers!

madmatt69

7:01 pm on Apr 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh wow, that's great, just what I was hoping to hear :) Thanks!

tstaheli

10:43 pm on Apr 6, 2003 (gmt 0)

10+ Year Member



Matt,
phpMyAdmin has an export to CSV feature built in. It's great free software to manage MySQL databases!

madmatt69

11:11 pm on Apr 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're kidding! I'm gonna install that and see how it works. Do you know if there's a way that you can implement a function on a webpage so that a user can generate that file, without having to actually use phpMyAdmin? The client needs to be able to generate the file on their own.