|
|
|
รบกวนถามหน่อยครับ พอดีผมจะสร้างตัวแปรแล้วเก็บ ตารางที่ดึงมาจาก DB ทำไงหรอครับ $a = .... |
|
|
|
|
|
|
|
Code (PHP)
$a = "<table border='2' cellpadding='3' cellspacing='0'>\n""
$a .= "<tr bgcolor=",$bgcolor,">"
แบบนี้ครับ ใช้ $a .=
|
|
|
|
|
Date :
2012-01-05 06:19:50 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
include('conn_mysql.php');
$query = "SELECT * FROM masterlist where documentid = '$documentid'";
$result = mysql_query($query) or die("Query failed");
if(mysql_num_rows($result) == 0){
$a .= "<span style=\'color: #330000;\'>No Document Found !</span>";
}else{
$bgcolor = "#E0E0E0";
$a = "<table border='2' cellpadding='3' cellspacing='0'>\n";
$a .= "<tr bgcolor=".$bgcolor.">\n";
$a .= "<th><span style=\"color: #330000;\">Ducument Name</th></span>
<th><span style=\"color: #330000;\">File Name</th></span>
<th><span style=\"color: #330000;\">Download</th></span></tr>";
while ($row = mysql_fetch_array($result)) {
$filepath = $row["filepath"];
$filename = $row["filename"];
$name = $row["name"];
if ($bgcolor == "#DFE6EF"){
$bgcolor = " #FFFFCC";
}else{
$bgcolor = "#DFE6EF";
}
echo "<tr bgcolor=",$bgcolor,">";
$a .= "<td><span style=\'color: #330000;\'>".$row['title']."</td></span>\n";
$a .= "<td><span style=\'color: #330000;\'>".$row['filename']."</td></span>\n";
$a .= "<td> <center><span style=\"color: #330000;\"><a href=\"download.php?filepath=$filepath&filename=$filename\">Download</center></span></a></td>\n";
$a .= print"\t</tr>\n";
$a .= print"\t</tr>\n";
}
$a .= print"</table>\n";
mysql_close($conn);
}
echo "$a";
$strMessage = nl2br($msg1);
$strMessage .= nl2br($a);
$flgSend = mail($strTo,$strSubject,$strMessage,$strHeader);
if($flgSend)
{
echo "<script>alert('ระบบได้ส่งคำร้องการจัดทำเอกสารเรียบร้อย!!');</script>";
}
else
{
echo "<script>alert('เกิดข้อผิดพลาดในการส่งคำร้องขอ!!');</script>";
}
ทำไมยังไม่ได้ ส่งเมล์ไม่ได้ครับ ช่วยดูโค็ตให้หน่อยครับ
|
|
|
|
|
Date :
2012-01-05 11:49:58 |
By :
beer656 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วทำไมต้องสร้างตัวแปร a ละครับ แค่ส่งเมลเฉยๆไม่ใช่หรอ
|
|
|
|
|
Date :
2012-01-05 12:44:27 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดูตัวอย่างนี้ครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Sending Email</title>
</head>
<body>
<?
$strTo = "[email protected]";
$strSubject = "Test Send Email";
$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]";
$strVar = "My Message";
$strMessage = "
<h1>My Message</h1><br>
<table width='285' border='1'>
<tr>
<td><div align='center'><strong>My Message </strong></div></td>
<td><div align='center'><font color='red'>My Message</font></div></td>
<td><div align='center'><font size='2'>My Message</font></div></td>
</tr>
";
$strSQL = "SELECT * FROM table-name";
$objQuery = mysql_query($strSQL);
while($objResult = mysql_fetch_array($objQuery))
{
$strMessage .= "<tr>
<td><div align='center'>".$objResult["item1"]."</div></td>
<td><div align='center'>".$objResult["item2"]."</div></td>
<td><div align='center'>".$objResult["item3"]."</div></td>
</tr>";
}
$strMessage .= "</table>";
$flgSend = @mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Email Sending.";
}
else
{
echo "Email Can Not Send.";
}
?>
</body>
</html>
|
|
|
|
|
Date :
2012-01-05 13:05:44 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|