Link to home
Start Free TrialLog in
Avatar of srinut31
srinut31

asked on

displaying mysql data in microsoft word using php

i am using  a php program  which displays data(retrieved from mysql database)  in microosoft word. i am using a linux server. using headers i am mentioning the word related header info. and echoing the data.
But actually the problem while displaying this content microsoft word application asks for converter to be installed and try to install if we cancel the installation it displays the data . Is there any way to  just putting text retrieved from database and displaying it as it is in word with out any further installation queryies and charset quries.
for reference i am  giving the code  i have used.

--------------------
my application requires just output the content from database in a word file using php. iam using a linux server.



<?php
 
ob_start();
 
session_start();
 
if((!session_is_registered(myusername) ) && (!session_is_registered(mypassword))){
 
header("location:index.html");
 
}
 
?>
 
<?php $id =$_SESSION['uid'];$uname =$_SESSION['name'];$FC =$_SESSION['FCAT'];$C =$_SESSION['myusername'];$C1 =$_SESSION['CLIENT'];
 
 
 
$EM=$_SESSION['EMAIL'] ;
 
if(($FC!=8)&&($FC!=9))
 
header("location:index.html");
 
$display=1;include("include.php");
 
$SNO =$reqid;
 
if($display)
 
{
 
 
 
if($FC==9)
 
{
 
 
 
 
 
 
 
$query  = "SELECT RES_DET from
 
xxxxx S , xxx R
 
 WHERE 
 
 S. ASSIGN =1
 
 AND 
 
 
 
S.RQID ='$SNO'
 
 
 
 
 
AND S.RESID ='$resid'
 
 
 
and S.RESID=R.FRID
 
 ";}
 
else
 
{
 
 
 
$query  = "SELECT RES_DET from
 
 xxxx S ,xxxx R
 
 WHERE  
 
 
 
 S.ASSIGN =1  AND
 
 
 
S.RQID ='$SNO'
 
AND S.RESID ='$resid'
 
 
 
 
 
 ";
 
 
 
 
 
 
 
}
 
$result = mysql_query($query)or die( "<center><h3><B>".mysql_error()."<br><A HREF='javascript:javascript:history.go(-1)'>Click here to go back to previous page<br><Br><Br></A>");
 
 
 
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
 
{
 
$RES_DET =$row['RES_DET'];
 
}
 
}
 
?>
 
 
 
<?php
 
//$filename = "temp.txt";
 
 
 
 
 
 
 
$length = strlen($imagedata);
 
 
 
$mm_type="application/ms-word";
 
 
 
/*
 
header("Cache-Control: public, must-revalidate");
 
header("Pragma: hack"); // WTF? oh well, it works...
 
header("Content-Type:   $mm_type;charset=utf-8");
 
//header("Content-Length: " .(string)(filesize($myFile)) );
 
//header('Content-Disposition: attachment; filename="'.$filename.'"');
 
header("Content-Transfer-Encoding: binary\n");
 
//include("test.html");*/
 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 
header("Content-type: application/msword;charset=utf-8");
 
header("Content-Disposition: attachment; filename=Resume.doc");
 
header("Pragma: no-cache");
 
header('Content-Transfer-Encoding: none');
 
header("Expires: 0");
 
 
 
 echo"$RES_DET";
 
 
 
//And here echo the document's content instead of writing it into a file on your server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// echo"the file name is : ";
 
 ob_end_flush();
 
		mysql_close($con);
 
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of srinut31
srinut31

ASKER

hi  friend,
you know phpmyadmin software which exports  mysql database in terms of word , excel, sql , and other formats,  It can easily export any data in required format. with getting error. in my application i tried to disply out put in word file. but  it is asking for word converter and try to fetch files from office -2003  installtion cd.
Is there any possiblility of  displaying out put in microsoft word  of a php program  fetching data from database mysql. and  the application is on linux server
may be you can look for some plug ins / libraries in PEAR or other packages..

also take a look at in the /phpmyadmin itself how they do the export to WORD???

might have some libraries or packages to do that... try to use ..if you find that is best one.,

Thanks to you am doing same. when click on word file link in browser ms word asking for import a file from
msword pro11.msi .
    i  say no than only its opening . i dont want that message to see in browsers man
     
if you don't have ms-word support (stream, open office or other) on linux server... it may display some errors,
in server that support is there  but client side is want to install the some package man  
i tried with more data & more table structure data... it does not display as i wanted ... so.. i just want to point out ... it won't be accurate or exact as we want the report ...

infact my phpmyadmin is in windows... i did not tryout in linux
oh... check in the client whether do you have .doc support (ms-word installed or check the exported / created .doc file is also valid..
i am testing on client system . i have server also
how can i see in pdf format can you tel me  logudotcom
you mean, do you want to go for pdf creation file instead of .doc format?
ya , we had problem with .doc format from our client side can you give how can i do
i got it for pdf still our client wants to see on .doc format .this is for now bout i need for .doc only