将图片从数据库导出到word文件PHP

时间:2013-12-04 11:34:27

标签: php mysql image ms-word

我将图片导出到word文件时遇到了问题。

我编写了php脚本,它获取了我的mysql数据库的两列内容,然后将这些内容导出到word文件中。其中一列是图像。

脚本运行正常但我在将图像提取到word文件时遇到问题。它没有显示图像。

我需要知道将图像提取到word文件的方法。

<?php
include('config.php');
$silver_events=mysql_query("select * FROM tb_property Where property_id='34'; ");
$silver_events_row=mysql_fetch_array($silver_events);

$sample_text = $silver_events_row['property_name'];
$sample_text1 = $silver_events_row['property_image0'];

$word_xmlns = "xmlns:o='urn:schemas-microsoft-com:office:office' 
xmlns:w='urn:schemas-microsoft-com:office:word' 
 xmlns='http://www.w3.org/TR/REC-html40′";

 $word_xml_settings = " <xml><w:WordDocument>
      <w:View>Print</w:View><w:Zoom>100</w:Zoom>    
      </w:WordDocument></xml>";

   $word_landscape_style = "@page {size:8.5in 11.0in; margin:0.5in 0.31in 
        0.42in 0.25in;} div.Section1{page:Section1;}";

   $word_landscape_div_start = "<div class='Section1′>";
   $word_landscape_img='<img src="../user_image/ACN NAIR.jpg" />';
   $word_landscape_div_end = "</div>";

   $content = '<html '.$word_xmlns.'>
        <head>
    <title>Export Data to word document</title>'  
        .$word_xml_settings.'<style type="text/css">
        '.$word_landscape_style.' table,td {border:0px solid #FFFFFF;}
          </style>
    </head>
    <body>'.$word_landscape_div_start . $sample_text . 
        $sample_text1 . $word_landscape_img . $word_landscape_div_end.'
    <img src="'.$sample_text1.'"  /></body>
</html>';

  @header('Content-Type: application/msword');
  @header('Content-Length: '.strlen($content));
  @header('Content-disposition: inline; filename="Silver Events.doc"');
  echo $content;

 ?>

0 个答案:

没有答案