php
  • html
  • css
  • phpmailer
  • 2014-04-04 84 views 0 likes 
    0

    我正在從數據庫中獲取數據,並把它放在HTML表格,該HTML表格看起來不錯,但當我按發送按鈕的電子郵件發送一些時間的HTML表格不對齊在電子郵件中,它看起來像下面的日期是不是在特定coloumn對準HTML表格不對齊在phpmail函數

    enter image description here

    也是這樣

    enter image description here

    我不爲什麼顯示 「!」。任何一個可以指導爲什麼出現這種情況,感謝

    我的代碼:

    $text_mail.= "<table style='border:1px solid black;border-collapse:collapse;'> 
    <tr > 
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Country</th> 
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Network Name </th> 
    <th style='border:1px solid black; width:50px; padding:0 0 0 5px'>MCC</th> 
    <th style='border:1px solid black; width:50px; padding:0 0 0 5px'>MNC</th> 
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Old Price (Euro)</th>   
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>New Price (Euro)</th>   
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Change</th>  
    <th style='border:1px solid black; width:130px; padding:0 0 0 5px'>Valid From (DD.MM.YYYY) </th>   
    </tr>"; 
    
    while($row = mysql_fetch_array($queryRes)) 
    { 
    
        if($row['pricefrom']==0){ 
    
         $pricefrom="NA"; 
         $change="New Network"; 
    
        }else{ 
    
         $pricefrom= $row['pricefrom']; 
         $change= $row['statusto']; 
    
        } 
    
        if($row['priceto']==0){ 
    
         $priceto="NA"; 
         $change="Not Covered"; 
    
        }else{ 
    
         $priceto= $row['priceto']; 
         $change= $row['statusto']; 
    
    
        } 
    
    
    $text_mail.= "<tr>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['country'] . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['networkname'] . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mcc'] . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mnc'] . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $pricefrom . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $priceto . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $change . "</td>"; 
    $text_mail.= "<td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" .date('d.m.Y', $row['datetime']) . "</td>"; 
    $text_mail.= "</tr>"; 
    } 
    $text_mail.= "</table> <br><br>"; 
    
    +0

    你真的不應該發送HTML電子郵件。基於html的電子郵件是當今信息技術中最大的安全問題之一。考慮使用簡單的純文本電子郵件和鏈接指向顯示該html的頁面。在所有系統上安全性更高,更少煩人,負載更少,可以閱讀您的消息的人更多。 – arkascha

    回答

    1

    你應該嘗試這樣的:

    $text_mail.= "<tr> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['country'] . "</td> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['networkname'] . "</td> 
    <td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mcc'] . "</td> 
    <td style='border:1px solid black; width:50px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $row['mnc'] . "</td> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $pricefrom . "</td> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $priceto . "</td> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" . $change . "</td> 
    <td style='border:1px solid black; width:130px; padding:0 0 0 5px;'><span></span><span></span><span></span><span></span>" .date('d.m.Y', $row['datetime']) . "</td> 
    </tr>"; 
    
    相關問題