How email a PHP webpage with correct format to any email client? -
i having problem emailing php page correct format. page contain table made of simple <td>
, <tr>
, javascript making negative numbers turn in red, javascript show below:
<head> <style type="text/css"> td.negative { color : red; } </style> <script language="javascript" type="text/javascript"> <!-- function makenegative() { tds = document.getelementsbytagname('td'); (var i=0; i<tds.length; i++) { var temp = tds[i]; if (temp.firstchild.nodevalue.indexof('-') == 0) temp.classname = "negative"; } } //--> </script> </head> <body> <~~~~~~~tables goes here~~~~~~~> <script language="javascript" type="text/javascript"> <!-- makenegative(); //--> </script> </body>
i can display webpage correct format using internet browser:
but when mail phpmailer or mailsend.exe, format become confused, no more negative number in red , table messed up. below screenshot sending gmail account:
and here screenshot sending outlook(hotmail) account:
(you need @ least 10 reputation post more 2 links...... i'd better post link in comment, please check, thanks)
how can solve problem?
you need use inline css, lot of web email providers disable css style in style block like:
<style> </style>
so, need:
<td style="color: red;">-1</td>
for each.
also, has been pointed out creation can done purely in php. although, doesn't seem you're having problem that. if use inline styles, fine.
when pull data out of db, construct rows way:
$tablerows = ''; foreach($dbrows $row) { $number = $row['number']; if ($number < 0) { $tablerows .= '<tr><td style="color: red;">'.$number.'</td></tr>'; } else { $tablerows .= '<tr><td>'.$number.'</td></tr>'; } }
//$tablerows contain of row data html now.
you less code, wanted illustrate point.
Comments
Post a Comment