我使用這個類來創建HTML內容PHP HTML生成器類
http://code.google.com/p/php-class-html-generator/
我嘗試用這種方式來建立一個表,但是HTML結果是錯誤的...
$messalist = array(...);
$html = htmltag::createElement('table')->id($attr['id']);
foreach($messagelist as $message){
$html->addElement('tr')
->addElement('td')->setText($message['subject'])
->addElement('td')->setText($message['from'])
->addElement('td')->setText($message['date'])
->addElement('td')->setText($message['size']);
}
echo $html;
怎麼辦它在正確的方式? 感謝
這是生成的html:
<table id="messagelist">
<tr>
<td>
<td>
<td>
<td>1.91kB</td>23 Feb 11:56 AM</td>To: [email protected]</td>Re: helooo</td></tr>
<tr>
<td>
<td>
<td>
<td>1.67kB</td>27 Feb 6:56 AM</td>[email protected]</td>Re: Helloo</td></tr></table>
,這就是我需要:
<table id="messagelist">
<tr>
<td>1.91kB<td></td>23 Feb 11:56 AM</td><td>To: [email protected]</td><td>Re: helooo</td></tr>
<tr>
<td>1.67kB</td><td>27 Feb 6:56 AM</td><td>[email protected]</td><td>Re: Helloo</td></tr></table>
它生成了什麼HTML? – 2012-03-07 14:37:26
剛剛發佈.. – Ste 2012-03-07 16:14:40