Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing MySQL data to MS Word Document with PHP

Status
Not open for further replies.

frummel

Technical User
Jun 21, 2002
91
NL
Hi there,

I want to read the content from my MySQL database and put it into a Word-Document that is created on the fly from a Word-template (with Bookmarks). All this must happen with a PHP script.

My system's configuration: Fedora Core 1 with PHP 4.3.2 and MySQL.

So I went searching everywhere for a script that does what I described above.
I found several manuals, that referred to COM support. Nice scripts, but this doesn't work on my Linux box.
So i figured I use:
Header("Content-type: application/msword");
Header("Content-Disposition: attachment; filename=test.doc");

A document is created though, and MS Word opens.
But how can I get say TABLE_A in MySQL get into BOOKMARK_A in my Word-Document?

The manuals (among many others) that I already checked are:

thread434-732530
 
What you want to do is damned difficult from a non-Win32 OS. The Word .doc file format can be most charitably described as "eccentric" -- that's why everyone uses Mi¢ro$oft's COM objects to create Word documents on the fly.

I've seen some PHP classes that will produce RTF documents on the fly. But none of them are free.

I recommend that you either produce another document format that Word can open, or use MyODBC and Word's database connectivity.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I did a fair chunk of R&D with COM, even under M$Windoze its not great, under anything else, sleipnir214 said it all :)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Have you considered using RTF format instead of Word documents? It is more straight forward than the eccentric MS format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top