Click here to Skip to main content
15,895,667 members

how to read and display MS word document using PHP

MuthuGanesh D asked:

Open original thread
Hi,

I want to read and display MS word document with out changing its formates (like paragraph, color, bold, etc).

I already try the following code.

PHP
<?php
$id=$_GET["id"];
include("config/opendb.php");

$sql="SELECT path FROM job_apply WHERE id= '$id'";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
header('Content-Type: text/html');
$file = $row['path'];
$data = file($file) or die('Could not read file!');
foreach ($data as $line) {
echo nl2br($line);
};
}
include("config/closedb.php");
?>



but this code given following output:


ÐÏࡱá>þÿ •—
þÿÿÿ“”ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥Á[€ ð¿Abjbj¬ú¬ú .Tΐ
ΐ
Aÿÿÿÿÿÿ·èè+++++ÿÿÿÿ????T“¤?3©t
77777Ö¨بببببب§ª¢I­zب+ب++77Ûí¨¶¶¶^+7+7Ö¨¶Ö¨¶¶&šœ°®§7ÿÿÿÿ —¸KÚ™Ë
?pJ d¨©03©® í†0
íȮ§Ã­+®§
¶بب¶3©ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿíè ñ:

HALL MASTER
Hall Id
Hall Name
Class
Section
Hall Capacity (No. of Student sit while exam).
CLASS MASTER
Class Id
Class Name (Standard)
SECTION MASTER
Section
DESIGNATION MASTER
Desg Id
Desg. Name
SUBJECT MASTER
Subj. Id
Subj. Name
Class Id
TERM MASTER
Term Id
Term Name
FEES MASTER
Fee Id
Class Id
Term Id
Fees Amount
-------------------------------------------------------------
Some undefined codes are display. Here i also use bold, color, etc.

I want to display that formates also.

Anybody have ideas....

Thanks.....
Tags: HTML, PHP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900