作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
只要我只有 1 行,从数据库中提取的数据就可以毫无问题地插入到 RTF 模板中。但是,如果我将 header("Content-type: text/rtf")
放在循环中,我会收到一个 headers already sent 错误。从代码中删除 header 时,原始数据会在浏览器窗口中正确打印。
如何合并数据库中多个记录的数据以创建多个文档(或 1 个带分页符的文档)?
代码在这里:
$document='../docs/letter.rtf';
$qry="Select * from table";
$result=mysql_query($qry);
$num_row=mysql_num_rows($result);
while($row=mysql_fetch_assoc($result)){
$account_id=$row['pk_account];
$name=$row['first_name'];
$file_doc='01-'.$pk_account.'.rtf';
....
$body=file_get_contents($document);
$body=str_replace("NAME", $name, $body);
....
for($i=0; $i<$num_rows; $i++){
}
header("Content-type: text/rtf");
header("Content-Disposition:attachment; filename={$file_doc}");
echo $body;
}
最佳答案
您需要连接您的 $body。所以不是这个:
$body=file_get_contents($document);
$body=str_replace("NAME", $name, $body);
试试这个:
$body.=str_replace("NAME", $name, file_get_contents($document));
然后把它放在你的 while 循环之外:
header("Content-type: text/rtf");
header("Content-Disposition:attachment; filename={$file_doc}");
echo $body;
关于mysql - 将 MySQL 数据导出到创建多个页面的 RTF 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12922710/
我在 StackOverflow 和其他地方看到了很多与此类似的问题,但没有一个直接解决我的问题。我正在 THREE.js 中使用凸包生成器生成 n 边多面体。我想将方形纹理映射到每个多面体的每个面上
我是一名优秀的程序员,十分优秀!