I was been in charge for a system that still using HTML_TO_DOC() with PHP. My question is, i want to display all data from database using table.
Here is my coding example:
$htmlContent=$html_2.' <table width=100% border=1 cellpadding="3" cellspacing="0"> <tr> <th width="5" bgcolor="#999999" class="style8">BIL</th> <th bgcolor="#999999" class="style8">NAMA</th> <th width="15" bgcolor="#999999" class="style8">JAWATAN</th> <th width="10" bgcolor="#999999" class="style8">TELEFON</th> <th width="10" bgcolor="#999999" class="style8">EMEL</th> </tr> '; $i=0; foreach($penyelaras as $plaras){ $htmlContent2=$html_2.' <tr> <td width="5" class="style8" valign="top">'.$i.'</td> <td align="left" class="style10" valign="top">'.$plaras->nama.'</td> <td width="15" class="style10" valign="top">'.$plaras->nama_jawatan.'</td> <td width="10" class="style10" valign="top">PEJ:'.$plaras->tel_no_p.'<br>HP:'.$plaras->tel_no_hp.'</td> <td width="10" class="style8" valign="top">'.$plaras->emel.'</td> </tr> '; $i++; } $htmlContent=$html_3.' </table> '; $soalan=$htmlContent.$htmlContent2; $htmltodoc->createDoc($soalan,"cetakan",true);
The result only shows 1 row only just like image (resulterror) below. Please help if i got mistake in my looping statement.
resulterror
Advertisement
Answer
$head ='<table width=100% border=1 cellpadding="3" cellspacing="0"> <tr> <th width="5" bgcolor="#999999" class="style8">BIL</th> <th bgcolor="#999999" class="style8">NAMA</th> <th width="15" bgcolor="#999999" class="style8">JAWATAN</th> <th width="10" bgcolor="#999999" class="style8">TELEFON</th> <th width="10" bgcolor="#999999" class="style8">EMEL</th> </tr>'; $i=0; $Content2 = ""; foreach($penyelaras as $plaras){ $Content2 .= '<tr> <td width="5" class="style8" valign="top">'.$i.'</td> <td align="left" class="style10" valign="top">'.$plaras->nama.'</td> <td width="15" class="style10" valign="top">'.$plaras->nama_jawatan.'</td> <td width="10" class="style10" valign="top">PEJ:'.$plaras->tel_no_p.'<br>HP:'.$plaras->tel_no_hp.'</td> <td width="10" class="style8" valign="top">'.$plaras->emel.'</td> </tr>'; $i++; } $soalan=$head.$Content2.'</table>'; $htmltodoc->createDoc($soalan,"cetakan",true);