通过我的数据库发送数据... ?? [英] emailing data from my DB...??

查看:47
本文介绍了通过我的数据库发送数据... ??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一段时间了,并且已经得到了

无处...希望有人在这里可以提供帮助。


我想要当这个php页面运行时,接收并通过电子邮件发送当前

日期的数据库中的所有记录。


现在我在这个数据库中有许多表......看起来像这样:

社论

编辑,编辑名称,编辑评论

press

pressdate,pressname,新闻评论

邮件

maildate,mailname,mailcomments


所以我想做的就是今天花几美元把它放进去吧进入一封

的电子邮件,电子邮件将如下所示:

==

编辑报告:

editorialdate < br $>
社论名称

编辑评论


邮件报告:

maildate

mailname

邮件评论


等...


这是我现在拥有的,我认为会这样做:


生成并通过电子邮件发送报告:

<?php

$ today = date(" M j,Y,");

echo $ today;


$ host =" localhost" ;;

$ user =" root";

$ pass ="" ;;

$ db =" productiondb";

$ con = mysql_connect($ host,$ user,$ pass);


if(!$ con)

{

die(''无法连接:''。 mysql_error());

}

mysql_select_db($ db,$ con)或死(''无法连接:''。

mysql_error());


$ sql =" SELECT * FROM editorial WHERE editorialdate LIKE''$ today%''" ;;


$ result = mysql_query($ sql,$ con); //实际运行查询


if(mysql_num_rows($ result)){//如果有结果

while($ row = mysql_fetch_array($ result) )){//将值放入

$ row

print $ row-> editorialdate;

print $ row-> editorialname ;

打印$ row->编辑评论;

}

}


//这个部分发送电子邮件

ini_set(" SMTP"," texchange.company.com");

ini_set(" smtp_port"," 25");

$ to =" pa ** @ company.com";

$ subject ="生产报告" ;;

$ txt =" ; $ row [0] \ n \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ $ headers ="来自: Da ************ ****@company.com " ;;

邮件($ to,$ subject,$ txt,$ headers); #< ---发送电子邮件


mysql_close($ con); //关闭与DB的连接


?>

今天我的$工作正常,因为在一开始它会说:

生成并通过电子邮件发送报告:2007年12月21日,


所以我知道这是正确的约会....所以我正在尝试这个...
现在我的数据库中的
表....我得到的是一封空白的电子邮件,其中没有数据来自我的数据库。


任何人有任何想法吗?

I''ve been working on this for some time now and have gotten
nowhere...hoping someone here can help.

I want to take and email all records in a database for the current
date when this php page is run.

Now I have a number of tables in this database...looking like this:
editorial
editorialdate, editorialname, editorialcomments
press
pressdate, pressname, presscomments
mail
maildate, mailname, mailcomments

So what I want to do is take anything for $today and put it into an
email, the email would look like this:
==
Editorial Report:
editorialdate
editorialname
editorialcomments

Mail Report:
maildate
mailname
mailcomments

etc...

here is what I have now, wich I thought would do it:

Generating and emailing report for:
<?php
$today = date("M j, Y,");
echo $today;

$host="localhost";
$user="root";
$pass="";
$db="productiondb";
$con = mysql_connect($host, $user, $pass);

if (!$con)
{
die(''Unable to connect: '' . mysql_error());
}
mysql_select_db($db, $con) or die(''Unable to connect: '' .
mysql_error());

$sql = "SELECT * FROM editorial WHERE editorialdate LIKE ''$today%'' ";

$result = mysql_query($sql,$con); // actually runs the query

if (mysql_num_rows($result)) { // if there are results
while ($row = mysql_fetch_array($result)) { // puts the values into
$row
print $row->editorialdate;
print $row->editorialname;
print $row->editorialcomments;
}
}

//this part sends email
ini_set("SMTP", "texchange.company.com");
ini_set("smtp_port", "25");
$to = "pa**@company.com";
$subject = "Production report";
$txt = "$row[0] \n\r\n\rPLEASE DO NOT REPLY TO THIS EMAIL, THIS IS NOT
A VALID EMAIL ADDRESS";
$headers = "From: Da****************@company.com";
mail($to,$subject,$txt,$headers); # <--- sends the email

mysql_close($con); //closes the connection to the DB

?>
my $today works fine because at the very beginning it will say:
Generating and emailing report for: Dec 21, 2007,

So I know it is getting the right date....so I am trying this for one
table in my DB now....and all I get is a blank email with no data in
it from my database.

Anyone have any ideas?

推荐答案

今天把它放到一封

的电子邮件中,电子邮件看起来像这样: br $>
==

编辑报告:

编辑日期

编辑名称

编辑评论

邮件报告:

maildate

mailname

mailcomments


等......


这就是我现在所拥有的,我认为会这样做:


生成并通过电子邮件发送报告:

<?php
today and put it into an
email, the email would look like this:
==
Editorial Report:
editorialdate
editorialname
editorialcomments

Mail Report:
maildate
mailname
mailcomments

etc...

here is what I have now, wich I thought would do it:

Generating and emailing report for:
<?php


今天= dat e(M j,Y,);

echo
today = date("M j, Y,");
echo


今天;

today;

这篇关于通过我的数据库发送数据... ??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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