Reputation: 315
Without using echo, how do I get the $report
array of records to populate this html table?
The first row $report[0]
shows up fine but I'm not sure how to get it loop through the table and automatically display the other rows.
$report = get_field('maths_month_report');
$report1 = $report[0];
$report2 = implode('</td><td>', $report1);
if (in_array('Maths', $subjecttitle)) {
return '
<table width="100%" id="report">
<tr>
<th width="10%">Month</th>
<th width="10%">Progress</th>
<th width="10%">Well-being</th>
<th width="35%">Remarks</th>
<th width="35%">Target</th>
</tr>
<tr>
<td>'. $report2 .'</td>
</tr>
</table>
';
}
Upvotes: 0
Views: 97
Reputation: 1015
$str = '<table width="100%" id="report">';
$str .= '<tr>
<th width="10%">Month</th>
<th width="10%">Progress</th>
<th width="10%">Well-being</th>
<th width="35%">Remarks</th>
<th width="35%">Target</th>
</tr>';
foreach($report as $v){
$str .= '<tr>
<td>'. $v['val1'] .'</td>
<td>'. $v['val2'] .'</td>
<td>'. $v['val3'] .'</td>
<td>'. $v['val4'] .'</td>
<td>'. $v['val5'] .'</td>
</tr>';
}
$str .= '</table>';
return $str;
i hope it will help you
Upvotes: 1