PHP邮件中的动态HTML表 [英] Dynamic HTML Table in PHP Mail

查看:99
本文介绍了PHP邮件中的动态HTML表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想知道我们可以在PHP Mail中包含一个用户定义的函数。

  $ to =example @ example.com; 
$ message ='< html>';
$ message。='< / html>';
$ from =webmaster@example.com;
$ headers ='MIME-Version:1.0'。 \r\\\
;
$ headers。='Content-Type:text / html; charset = ISO-8859-1'。 \r\\\
;
$ headers。=From:。从$;

我尝试了上面的代码,我只是收到消息' / html>'(没有引号)在我的邮件。并且该功能被打印在屏幕上。我不想将该功能打印在屏幕上,我想要运行该功能,并将内容邮寄给用户。 BTW的功能是从MYSQL数据库动态生成的HTML表。我在互联网上搜索,但找不到任何具体的答案。

解决方案

几率您的 displayWinesList() function echo的数据而不是返回它。



您可以调用函数返回数据或按原样保留并使用输出缓冲来捕获数据:

  $ to =example@example.com; 
$ subject =WineStore Query;
ob_start();
displayWinesList($ connection,$ query,$ region_name,$ wine_type,$ price);
$ message = ob_get_clean();
$ message ='< html>'。$ message。'< / html>';
$ from =webmaster@example.com;
...

要知道某些信息,请发布您的 displayWinesList )函数。


I Just wanted to know can we can we include a user defined function in the PHP Mail

$to = "example@example.com";
$message = '<html>';
$message .='</html>';
$from = "webmaster@example.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= "From:" . $from;

I tried the above code and i just get the message '< /html>'(without quotes) in my mail. And the function gets printed on the screen. I dont want the function to be printed on the screen i want the function to be run and the contents to be mailed to the user. BTW the function is dynamically generated HTML Table from a MYSQL Database. I've searched on the internet but couldn't find any specific answer.

解决方案

Chances are your displayWinesList() function echo's its data instead of returning it.

You can either mod your function to return the data or leave it as-is and use output buffering to capture the data:

$to = "example@example.com";
$subject = "WineStore Query";
ob_start();
displayWinesList($connection, $query,$region_name, $wine_type, $price);
$message = ob_get_clean();
$message = '<html>'.$message.'</html>';
$from = "webmaster@example.com";
…

To know for certain however please post your displayWinesList() function.

这篇关于PHP邮件中的动态HTML表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆