【发布时间】:2015-05-14 12:03:44
【问题描述】:
我需要使用 php 邮件功能发送邮件。需要count早餐、午餐、晚上、晚餐、午夜每天(从今天到接下来的 7 天),其中每个字段都标记为“1”。
Mysql 表和数据
需要count每天(从今天到接下来的 7 天)的 BREAKFAST、LUNCH、EVENING、DINNER、MIDNIGHT(从今天到接下来的 7 天),其中每个字段都标记为“ 1"。
要循环的最简单的查询:-
从 foodPlan 中选择 count(BREAKFAST),其中 BREAKFAST=1 和 date="2014-09-17";
这样,从今天到连续 7 天逐行 列 - BREAKFAST、LUNCH、EVENING、DINNER、MIDNIGHT - 每个列都应提供标记为“1”的计数,无需计算。
结果需要与这些数据一起邮寄:-
$link =mysql_connect("172.17.xx.xxx", "username", "password")
or die(mysql_error());
//To select the database
mysql_select_db("dbname") or die(mysql_error());
//To get the current date
$date=date("Y-m-d");
$dates = array();
$dates[0] = $today;
for ($i=1; $i<7; $i++) {
$dates[$i] = date('Y-m-d', strtotime("+$i day"));
}
.....
.....
# This will set the Subject for the Mail
$subject = "FOODIE plan";
$recipient = 'xx@yyyy.com';
# The following details will be updated in the Body part of the mail
$message = "Foodie";
....
....
mail ( $recipient, $subject, $message, $header );
邮件中的数据应如下所示:-
【问题讨论】:
-
请告诉我们你做了什么?
-
请查看编辑@Alankar
-
你能显示你得到的数组吗?
-
需要将mysql查询的结果打印成报告格式。
-
这看起来很糟糕的设计
标签: php mysql email multidimensional-array foreach