0
我想通過郵件發送目錄。該表由另一個php文件生成。
代碼如下:郵件PHP/html輸出
<?php
//include database configuration
include 'connectdb.php';
//selecting records
$sql='select i.id, i.description, u.firstname, i.created_on, u1.firstname, i.closed_on,
i.id AS id,
i.description AS description,
u.firstname AS firstname,
i.created_on AS created_on,
u1.firstname AS u1_firstname,
i.closed_on AS closed_on
from issues AS i
INNER JOIN users AS u ON i.author_id = u.id
INNER JOIN users AS u1 ON i.assigned_to_id = u1.id';
//query the database
$rs=mysqli_query($conn,$sql) or die($sql.">>".mysqli_error($conn));
//count how many records found
$num=mysqli_num_rows($rs);
if($num>0){ //check if more than 0 record found
?>
<table border='1'>
<tr>
<th>Issue ID</th>
<th>Description</th>
<th>Raised by</th>
<th>Raised on</th>
<th>Assigned to</th>
<th>Current State</th>
</tr>
<?php
echo $num;
//retrieve our table contents
while($row=mysqli_fetch_array($rs)){
//extract row
//this will make $row['firstname'] to
//just $firstname only
extract($row);
if($closed_on === null){
//refering to other tables
//$dateob=substr($DOB,8,2).'-'.substr($DOB,5,2).'-'.substr($DOB,0,4);
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $description; ?></td>
<td><?php echo $firstname; ?></td>
<td><?php echo $created_on; ?></td>
<td><?php echo $u1_firstname; ?></td>
<td><?php
echo 'Open Ticket';
?></td>
</tr>
<?php
}
}
}
else{ //if no records found
echo "No records found.";
}
?>
</table>
瞭解輸出緩衝:HTTP ://web.archive.org/web/20101216035343/http://dev-tips.com/featured/output-buffering-for-web-developers-a-beginners-guide – Ananth
請不要將標記爲PHPMailer,如果您沒有使用PHPMailer。 – Synchro