我,我的东西堆栈,似乎并没有变得更好。 是否可以使用一个脚本来单独获取每个客户端行数据并将其发送到他们的电子邮件地址? 还在努力,但我无法找到答案。
任何有很好建议的人?
这是我的代码:
<?php
$sqlSelect = "SELECT
cl.client_name,
DATE(jb.date),
jb.job_number,
jb.repair,
st.site_name
FROM
job_cards jb
INNER JOIN
clients cl ON (cl.client_id = jb.client_id)
LEFT JOIN
sites st on (st.site_id = jb.site_id)
WHERE
jb.completed = 1
AND cl.client_id = jb.client_id
ORDER BY cl.client_name ASC";
$tresult = mysql_query($sqlSelect);
while($userData = mysql_fetch_assoc($tresult))
{
if($i%2==0)
$classname = 'evenRow';
else if($i%2==1)
?>
<tr class='<?php if(isset($classname)) echo $classname;?>'>
<td width=250>
<?php
//echo $userData['client_name)'];
echo mysql_real_escape_string ($userData['client_name]); ?>
</td>
<td width=100>
<?php echo mysql_real_escape_string ($userData['DATE(jb.date)']); ?>
</td>
<td width=50>
<?php echo mysql_real_escape_string($userData['job_number']);?>
</td>
<td>
<?php echo mysql_real_escape_string($userData['site_name']);?>
</td>
<td>
<?php echo mysql_real_escape_string($userData['repair']);?>
</td>
<?php
$to .= "realconcept@usa.com";
$subject ="Monthly Reports for company";
$headers .='MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'From: System Admin <mike@guardre.com>' . "\r\n";//<noreply@example.com>'
$message .="
Company Name : ".$userData['client_name']."\n".
"Date : ".$userData['DATE(jb.date)']."\n".
"Site : ".$userData['site_name']."\n".
"Description : ".$userData['repair']."\n";
if(mail('realconcept@usa.com', $subject, $message, $header))
$i++;
}
?>
**我的代码出了什么问题?** s