0

ここ数時間、メール内に動的テーブルを作成しようと試みてきました..そして、私は失敗しました。ボディ変数の内外にテーブルを作成し、その中でエコーしようとしましたが、成功しませんでした私のコードを以下に配置しました..どんな助けでも大歓迎です..私がやろうとしているのは、その中にいくつかのmysqlデータを含むテーブルを作成し、それをいくつかのクライアントに送信することだけです..

$link = mysql_connect('localhost', 'root', '');
    mysql_select_db('netbookdb');
    $sql="SELECT * FROM rep_log WHERE s_date = '2012-05-31'";
    $result=mysql_query($sql, $link);


$date=date('dmy');
require("../PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();    // set mailer to use SMTP
$mail->Host = "smtp";    // specify main and backup server

$mail->From = "support@.vic.edu.au";    
$mail->FromName = "Ict Devices";   
$mail->AddAddress("email@h.vic.edu.au", "Matthew");


$mail->Subject = "Damage Log Report";

$mail->IsHTML(true);
$var='xlsx';
$date=date('dmy.');

$mail->Body = " while($rows=mysql_fetch_array($result)){
        $cases=$rows['cases'];
        $hg=$rows['hg'];
        $surname=$rows['surname'];
        $firstname=$rows['firstname'];
        $claim=$rows['claim'];
        $damage=$rows['damage'];
        $cost=$rows['cost'];

    }";
$mail->AltBody="Please Use a Html Compaible Email Veiwer";



if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "Letter is sent";
}
4

1 に答える 1

1

作成したこのPeaceofCodeを使用して、動的なテーブルを作成するスクリプトを取得し、それを電子メールの本文にエコーアウトしました。これは基本的なテーブルにすぎませんが、改善することができます。

$link = mysql_connect('localhost', 'root', '');
    mysql_select_db('Your Dataabse name');
    $sql="SELECT * FROM rep_log WHERE claim='Insurance' AND s_date = '2012-05-31'";
    $result=mysql_query($sql, $link);

$table= "<table width='100%' border='3' cellspacing='0' cellpadding='0'>";
$table .="<th>Cases</th>";
$table .="<th>HG</th>";
$table .="<th>Surname</th>";
$table .="<th>FristName</th>";
$table .="<th>Claim</th>";
$table .="<th>Damage</th>";
$table .="<th>Cost</th>";

    while($rows=mysql_fetch_array($result)){
        $cases=$rows['cases'];
        $hg=$rows['hg'];
        $surname=$rows['surname'];
        $firstname=$rows['firstname'];
        $claim=$rows['claim'];
        $damage=$rows['damage'];
        $cost=$rows['cost'];
    $table .="<tr>";
    $table .="<td>$cases</td>";
    $table .="<td>$hg</td>";
    $table .="<td>$surname</td>";
    $table .="<td>$firstname</td>";
    $table .="<td>$claim</td>";
    $table .="<td>$damage</td>";
    $table .="<td>$cost</td>";
    $table .="</tr>";


    }
$table .="</table>";

$date=date('dmy');
require("../PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();    // set mailer to use SMTP
$mail->Host = "smtp";    // specify main and backup server

$mail->From = "support@ac.vic.edu.au";    
$mail->FromName = "Ict Devices";   
$mail->AddAddress("gs@hum.vic.edu.au", "Matthew");


$mail->Subject = "Damage Log Report";

$mail->IsHTML(true);
$var='xlsx';
$date=date('dmy.');

$mail->Body = "$table;";
$mail->AltBody="Please Use a Html Compaible Email Veiwer";



if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "Letter is sent";
}
于 2012-06-05T01:28:01.813 に答える