sandy1028 Posted February 27, 2008 Share Posted February 27, 2008 How to write the php script to open in a word format. I tried the code below which opens in word documetn but the contents are not dynamic. The word page is not getting refreshed $rec=clusteravail(); array_shift($rec); header("Content-type: application/msword"); echo "<html><head><title>REPORT</title><meta http-equiv=\"refresh\" content=\"100\"></head><body bgcolor=\"#FFFFFF\" text=\"#000000\"><TABLE BORDER=2 CELLPADDING=4 width=\"100%\"><TR><TH COLSPAN=8>DATE AS ON 2008-02-27</TH></TR><TR><TH COLSPAN=8>Head and CLIENT NODE Status of Garuda Network</TH></TR><TR><TD>SL NO</TD><TD>CLIENT NODE NAME</TD><TD>IP ADDRESS</TD><TD>HEAD NODE NAME</TD><TD>START TIME</TD><TD>END TIME</TD><TD>DURATION</TD></TR>"; for($i=0;$i<=count($rec);$i++){ $data=split("#",$rec[$i]); echo "<tr>"; echo "<td>$i</td>"; echo "<td>$data[0]</td>"; echo "<td>$data[1]</td>"; echo "<td>$data[2]</td>"; echo "<td>$data[3]</td>"; echo "<td>$data[4]</td>"; echo "<td>$data[5]</td>"; } echo "</tr></table></body></html>"; Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2008 Share Posted February 27, 2008 Your question is exactly? Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 The word document is not getting refreshed. It has to get refreshed when the value retrived from the database. But it is not happening. The page open the word document which was opened at the first time Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2008 Share Posted February 27, 2008 Of course that code will produce the same result each time, how exactly is your data changing? Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 From the database and which is updated for 2 minutes. But the word file is not changed Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 Please anyone tell me why the word document doesnot get updated when opened in word format Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2008 Share Posted February 27, 2008 Why are you using html within a word document? Word is not a web browser, and to be honest, im not sure html or the meta refresh tag are going to have any affect within it. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 I have to open a php page output in the word file and which it should be refreshed everytime. Can you suggest me how can I proceed with it Quote Link to comment Share on other sites More sharing options...
trq Posted February 27, 2008 Share Posted February 27, 2008 I haven't used any microsoft product in years so don't confess to being any expert, but I would suggest it can't be done. The whole idea doesn't make sense to be honest. Quote Link to comment Share on other sites More sharing options...
DarkerAngel Posted February 27, 2008 Share Posted February 27, 2008 I haven't used any microsoft product in years so don't confess to being any expert, but I would suggest it can't be done. The whole idea doesn't make sense to be honest. Well MS Word can handle HTML, and I never looked at it in Plain text but i think the new format (.docx) is all XML based. but this script should generate what evers in the strings provided. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 Can you send me good links. I just want the output of the php where the table and data in it should get refreshed. BUt the code which I tried will open in word format and doesnot get refreshed Quote Link to comment Share on other sites More sharing options...
aschk Posted February 27, 2008 Share Posted February 27, 2008 Sorry , i'm a little confused here. Why are you trying to output a word document? Quote Link to comment Share on other sites More sharing options...
aschk Posted February 27, 2008 Share Posted February 27, 2008 Ooh, just did a test and the header("Content-type: application/msword"); prompts you to download a word doc which when opened will actually contain the html that you are outputting. COOL! Now to go away and find a good implementation for that. What does clusteravail(); function do? This is where are you shifting the recordset, and i suspect is wrong. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted February 27, 2008 Author Share Posted February 27, 2008 Function clusteravail queries the mysql and returns the data. When I remove the header("...................') the output works fine. But when I include header to open in word it doesnot get updated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.