1
HTML 이메일을 보내는 PHP 스크립트가 있습니다. 데이터를 수집하고 변수에 저장하기 위해 'for'루프를 사용하고 있습니다. 루프는 25 회 실행하도록 지시됩니다. 문제는 단지 19 번만 루핑한다는 것입니다. 내가 unlcosed 태그 또는 구문에 오타가 있는지 확인했지만 찾지 못했습니다. 나는 당신이 혹시 내가 할 수없는 것을 발견 할 수있을 경우 for 루프 섹션을 게시하고있다. 해결책이 매우 간단하다고 생각하면서 실망 스럽지만 문제를 발견 할 수는 없습니다.PHP for 루프가 HTML 이메일 내부를 완전히 반복하지 않음
'mail()'함수의 헤더가 정상입니다. 여기에 그들이 여기
$headers = "From: $from \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
그리고 경우
에있는 것은 내 루프 : 나는 코드가 침입하는 방법에 대한 아이디어를 제공하기 위해 전송되는 이메일의 스크린 샷을 첨부 할 수 있습니다$abc ="<table width='600'>";
$abc .= "<tr>
<td bgcolor='#d6bf86'><span style='color:#9c2a00'>Number of Products</span></td>
<td align='center' bgcolor='#fde4d0'>$pagess</td>
<td align='center' bgcolor='#c3deb9'>$pagese</td>
<td align='center' bgcolor='#bee7f8'>$pagesu</td>
</tr>";
for($i=1; $i<=25; $i++)
{
$abc .="<tr>";
if($i % 2 == 0) // EVEN ROW
{
$abc .= "<td bgcolor='#d6bf86' width='260'><span style='color:#9c2a00'>".${f.$i}."</span></td>";
}
else // ODD ROW
{
$abc .= "<td bgcolor='#fffbd0' width='260'><span style='color:#9c2a00'>".${f.$i}."</span></td>";
}
if(isset(${s.$i}))
{
$abc .= "<td bgcolor='#fde4d0' align='center'>Yes</td>";
${s.$i} = "Yes";
}
else
{
$abc .= "<td bgcolor='#fde4d0' align='center'>No</td>";
${s.$i} = "No";
}
if(isset(${e.$i}))
{
$abc .= "<td bgcolor='#c3deb9' align='center'>No</td>";
${e.$i} = "Yes";
}
else
{
$abc .= "<td bgcolor='#c3deb9' align='center'>Yes</td>";
${e.$i} = "No";
}
if(isset(${u.$i}))
{
$abc .= "<td bgcolor='#bee7f8' align='center'>No</td>";
${u.$i} = "Yes";
}
else
{
$abc .= "<td bgcolor='#bee7f8' align='center'>Yes</td>";
${u.$i} = "No";
}
$abc .="</tr>";
}
if(isset($_POST['dscs'])) // DISCOUNT HAS BEEN APPLIED
{
$abc .= "<tr>
<td>Base Price</td>
<td align='center'>$sums</td>
<td align='center'>$sume</td>
<td align='center'>$sumu</td>
</tr>";
$abc .= "<tr>
<td>Discount Offered</td>
<td align='center'>$discount% </td>
<td align='center'>$discount% </td>
<td align='center'>$discount% </td>
</tr>";
$abc .= "<tr>
<td>Effective Price</td>
<td align='center'>$dscs</td>
<td align='center'>$dsce</td>
<td align='center'>$dscu</td>
</tr>";
}
else
{
$dscs = $sums;
$dsce = $sume;
$dscu = $sumu;
$abc .= "<tr>
<td>Total Price</td>
<td align='center'>$sums</td>
<td align='center'>$sume</td>
<td align='center'>$sumu</td>
</tr>";
}
$abc .="</table>";
. 스크린 샷을 원한다면 알려주세요.
추신 :이 코드를 별도의 파일에 복사하여 실행하고 정상적으로 작동했습니다. 루프가 25 번 반복되었습니다. 이것은 HTML 전자 메일 안에 넣는 것이 문제라고 믿게합니다. 그 도움이된다면
은 또한 이메일 스크립트에 추가 : 사전에$to = $clem;
$subject = "Something goes here";
$message = "<html>
<head></head>
<body style='background-color:#ffffff; font-family:Lucida Sans Unicode, Lucida Grande, sans-serif;'>
<table width='600'>
<tr>
<td>$abc</td>
</tr>
</table>
</body>
</html>";
$from = "$logged_user";
$headers = "From: $from \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$res=mail($to,$subject,$message,$headers);
감사합니다, Nisar
= "
Ok Slayer. 나는 지금 당장 그것을 할 것이고 당신에게 잠시 후에 알려줄 것이다. 편집 : 그것은 19를 보여줍니다. 그래서 루프가 깨고 있습니다. – asprin
i ..의 가치는 무엇입니까? 1-19 또는 그 밖의 다른 것에서 계속됩니까? –
답변
신경 끄시를, 내가 잘못 무엇인지 발견했다. 여기에 비슷한 문제가있는 사람들을위한 것입니다. $의 ABC 후 루프에서
I learnt that html emails have a 990 character limit per line. That was the reason why my code was breaking
출처
2012-07-26 09:11:24 asprin
관련 문제