Learning & Integrating web technology and code help directory

How to use PHP & Word Using header(”Content-type: application/vnd.ms-word”)

No comments
How to use PHP & Word Using header(”Content-type: application/vnd.ms-word”); The Learn / tutorial php programming how to using  PHP export to Word document ,Word Using header(”Content-type: application/vnd.ms-word”);
ShotDev Focus:
- PHP  & Export to Word document ,Word Using header(”Content-type: application/vnd.ms-word”);.
Example
php_word_header.php

  1. <?  
  2. header("Content-type: application/vnd.ms-word");  
  3. header("Content-Disposition: attachment; filename=testing.doc");  
  4. ?>  
  5. <html>  
  6. <body>  
  7. <?  
  8. $objConnect = mysql_connect("localhost","root","root"or die(mysql_error());  
  9. $objDB = mysql_select_db("mydatabase");  
  10. $strSQL = "SELECT * FROM customer";  
  11. $objQuery = mysql_query($strSQLor die ("Error Query [".$strSQL."]");  
  12. ?>  
  13. <table width="600" border="1">  
  14. <tr>  
  15. <th width="91"> <div align="center">CustomerID </div></th>  
  16. <th width="98"> <div align="center">Name </div></th>  
  17. <th width="198"> <div align="center">Email </div></th>  
  18. <th width="97"> <div align="center">CountryCode </div></th>  
  19. <th width="59"> <div align="center">Budget </div></th>  
  20. <th width="71"> <div align="center">Used </div></th>  
  21. </tr>  
  22. <?  
  23. while($objResult = mysql_fetch_array($objQuery))  
  24. {  
  25. ?>  
  26. <tr>  
  27. <td><div align="center"><?=$objResult["CustomerID"];?></div></td>  
  28. <td><?=$objResult["Name"];?></td>  
  29. <td><?=$objResult["Email"];?></td>  
  30. <td><div align="center"><?=$objResult["CountryCode"];?></div></td>  
  31. <td align="right"><?=$objResult["Budget"];?></td>  
  32. <td align="right"><?=$objResult["Used"];?></td>  
  33. </tr>  
  34. <?  
  35. }  
  36. ?>  
  37. </table>  
  38. <?  
  39. mysql_close($objConnect);  
  40. ?>  
  41. </body>  
  42. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Word Using header(”Content-type: application/vnd.ms-word”);
PHP & Word Using header(”Content-type: application/vnd.ms-word”);
.
.

No comments :

Post a Comment