即時嘗試生成一個電子郵件,以包括一些排序的數據在正文中。 我的電子郵件發送但沒有正文中的數據。通過函數也是while循環,如果有意義的話,它們會生成回顯的html內容? 這裏是其中的一個功能。在字符串中的while循環中運行一個函數?
function ye($coid){
$yest = date("Y-m-d", time() - 86400);
$inouty= mysql_query("SELECT clockings.id AS cid,clockings.uid, clockings.con, clockings.coff, staff.sname ,staff.id, staff.act, staff.coid FROM clockings LEFT JOIN staff ON clockings.uid=staff.id WHERE clockings.dte = '$yest' AND staff.coid =$coid ORDER BY staff.id, clockings.id")or die(mysql_error());
while ($row = mysql_fetch_assoc($inouty)) {
$sname= $row['sname'];
$in= $row['con'];
$out= "- ". $row['coff'];
$id = $row['cid'];
echo"$sname $in $out<br>";}}
,這就是我稱之爲
$html_text = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Email</title>
</head>
<body>details Current status for $nicedate as of $now<br>". tod($coid)."<br>Yesterdays Clockings<br>". ye($coid)."</body>
</html>";
沒有,如果我改變函數返回一個值,而不是呼應的,我得到的結果,而不是完整循環的只是第一行,但就是包括在電子郵件正文文本中,並且當我在腳本結尾處使用echo函數調用函數時,我會得到所需的輸出。 有什麼辦法可以讓這個工作?在此先感謝尼克
你試過一個「沙箱」來回顯$ inouty?還單獨$ inouty並從那裏工作... – Pogrindis