techker Posted January 15, 2011 Share Posted January 15, 2011 Hey guys i found this script that works great for what i need .. se i have this script that i did for my body (loan application) now i would like to export the info in a word doc <?php $ExcelFileName="test.doc"; header("Content-type: application/x-ms-download"); header("Content-Disposition: attachment; filename=$ExcelFileName"); header('Cache-Control: public'); $content=<<<EOD echo 'php'; whatever you want to write here including a php script it will be included in a string and then go in the output for a doc file EOD; echo $content; ?> so im trying to eco all the content in the database.. i tryed all the DB connection is there.. ao i place this after the (echo 'php' while($info = mysql_fetch_array($fileLIST)){; echo $info['PERS_F_NAME']; }; i get this? Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/autosspe/public_html/admin/loan/word.php on line 21 Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/ Share on other sites More sharing options...
mckgr Posted January 15, 2011 Share Posted January 15, 2011 You have a semicolon at the end of the first line of your while loop. That's probably the cause. Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1159986 Share on other sites More sharing options...
techker Posted January 15, 2011 Author Share Posted January 15, 2011 even if i only put echo 'php'; echo $row3['PERS_F_NAME']; Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/autosspe/public_html/admin/loan/word.php on line 21 Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1159990 Share on other sites More sharing options...
kenrbnsn Posted January 16, 2011 Share Posted January 16, 2011 Please show use a few lines above those. Ken Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1160022 Share on other sites More sharing options...
techker Posted January 16, 2011 Author Share Posted January 16, 2011 ok so i got it going with this but i need to make each echo on a diffrent line??cause now it shows all in one.. <? header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=document_name.doc"); header("Pragma: no-cache"); $ID=$_GET['ID']; require "config.php"; $connection = mysql_connect($dbhost, $dbusername, $dbpass); $SelectedDB = mysql_select_db($dbname); $ID=$_GET['ID']; $q3 = "select * from APPLICATIONS where ID ='$ID'"; $res3 = mysql_query($q3); $row3 = mysql_fetch_assoc($res3); ?> <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=utf-8" /> </head> <body> <? echo $row3['PERS_F_NAME']; echo $row3['PERS_L_NAME']; echo $row3['PERS_DATE_BIRTH']; echo $row3['PERS_SSN']; echo $row3['PERS_DRIVERS_L']; echo $row3['PERS_ADD']; echo $row3['PERS_CITY']; echo $row3['PERS_CODE']; echo 'Less then 2 years'; echo $row3['PERS_ADD_2']; echo $row3['PERS_CITY_2']; echo $row3['PERS_CODE_2']; echo $row3['PERS_NUMBER']; echo $row3['PERS_CELL']; echo $row3['PERS_FAX']; echo $row3['EMPL_E']; echo $row3['EMPL_ADD']; echo $row3['EMPL_CITY']; echo $row3['EMPL_CODE']; echo $row3['EMPL_TYPE']; echo $row3['EMPL_SINCE']; echo $row3['EMPL_P']; echo $row3['EMPL_SUP']; echo $row3['EMPL_N']; echo $row3['EMPL_GS']; echo 'Less then 2 years'; echo $row3['EMPL_2_E']; echo $row3['EMPL_2_ADD']; echo $row3['EMPL_2_CITY']; echo $row3['EMPL_2_CODE']; echo $row3['EMPL_2_TYPE']; echo $row3['EMPL_2_SINCE']; echo $row3['EMPL_2_P']; echo $row3['EMPL_2_SUP']; echo $row3['EMPL_2_N']; echo $row3['EMPL_2_GS']; echo 'Assets & liabilities'; echo $row3['OTHER_OWN_RENT']; echo $row3['OTHER_OWN_RENT_D']; echo $row3['OTHER_OWN_RENT_V']; echo $row3['OTHER_OWN_RENT_AM']; echo $row3['OTHER_OWN_RENT_MP']; echo 'Assets & liabilities'; echo $row3['OTHER_CC_REER']; echo $row3['OTHER_CC_REER_D']; echo $row3['OTHER_CC_REER_V']; echo $row3['OTHER_CC_REER_AM']; echo $row3['OTHER_CC_REER_MP']; echo 'Assets & liabilities'; echo $row3['OTHER_INV_CAR']; echo $row3['OTHER_INV_CAR_D']; echo $row3['OTHER_INV_CAR_V']; echo $row3['OTHER_INV_CAR_AM']; echo $row3['OTHER_INV_CAR_MP']; echo 'Assets & liabilities'; echo $row3['OTHER_OTHER_L']; echo $row3['OTHER_OTHER_L_D']; echo $row3['OTHER_OTHER_L_V']; echo $row3['OTHER_OTHER_L_AM']; echo $row3['OTHER_OTHER_L_MP']; echo 'EMAIL'; echo $row3['EMAIL']; echo 'Accepted therms and conditions'; echo $row3['ACCEPT']; ?> </body> </html> <?php $vExcelFileName="export". ".doc"; header("Content-type: application/x-ms-download"); //#-- build header to download the excel file header("Content-Disposition: attachment; filename=$vExcelFileName"); header('Cache-Control: public'); echo "hai"; ?> Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1160035 Share on other sites More sharing options...
zenlord Posted January 16, 2011 Share Posted January 16, 2011 I haven't tested your code, but if you want to generate .docx or .odt-files from PHP and insert all kinds of variables into a document template, I can very much vouch for 'opentbs', a plugin for the 'TinyButStrong'-templating engine. It is very easy to use: you make a template in f.e. openoffice, in which you place some fields and then you submit some variables to the opentbs-object to generate a new .docx or .odt. Don't go reinventing the wheel Zl. Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1160371 Share on other sites More sharing options...
techker Posted January 16, 2011 Author Share Posted January 16, 2011 will check it out.its works fine do..i just inserted a br and all good Link to comment https://forums.phpfreaks.com/topic/224564-php-to-word/#findComment-1160379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.