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

将图片从数据库导出到word文件PHP,php,mysql,image,ms-word,Php,Mysql,Image,Ms 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_t

我在将图片导出到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;

 ?>
我已经编写了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;

 ?>

如果您将输出回显到屏幕上而不是直接导出到word中,您会看到正确的图像吗?@Stanyer是的,我可以在我的页面中看到正确的图像。相对URL(如)在从其他计算机引用到您的服务器时没有意义;或者为图像使用绝对URL,或者将图像数据作为base64编码流嵌入到标记中,这有帮助吗@标记,即使给出了实现此操作的绝对路径。图像未显示。