<?php
$rowTemplate = '
<tr>
<td id="{staffid}-s-fname">{fname}</td>
<td id="s-lname-{staffid}">{lname}</td>
<td id="s-dept-{staffid}">{dept}</td>
<td><input id="{staffid}-s-edit" name="btn_add" type="submit" class="s-edit btn btn-sm btn-primary" value="Edit" /></td>
<td><a href="{edit_url}">Edit</a></td>
</tr>';
?>
<tbody id="staff-table-body">
<?php
foreach ($data as $staff)
{
$detail_id = $staff['staffid'];
echo str_replace(
array('{staffid}', '{fname}', '{lname}', '{dept}', '{edit_url}'),
array($staff['staffid'], $staff['fname'], $staff['lname'], $staff['dept'], site_url("staff/edit_staff/{$staff['staffid']}")),
$rowTemplate
);
}
?>
</tbody>
</table>
<input type='hidden' id='rowTemplate' value='<?php echo $rowTemplate; ?>' />