PHP邮件中的动态HTML表 [英] Dynamic HTML Table in 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屋!