Het kan zo. In dit voorbeeld heb ik de $rows
hard hard gecodeerd array, maar je kunt dat vervangen door je array van rijen uit de database.
<?php
$rows = array(
array(
'name' => 'Juan',
'login' => '09:00:01',
'evaluation' => 'Yes'
),
array(
'name' => 'Juan',
'login' => '09:00:02',
'evaluation' => 'Yes'
),
array(
'name' => 'Juan',
'login' => '09:00:03',
'evaluation' => 'Yes'
),
array(
'name' => 'Jose',
'login' => '09:00:04',
'evaluation' => 'No'
),
array(
'name' => 'Jose',
'login' => '09:00:05',
'evaluation' => 'No'
)
);
?>
<table>
<tr>
<th>Name</th>
<th>Login</th>
<th>Evaluation</th>
</tr>
<?php
$prevName = '';
foreach($rows as $row):
if($prevName == $row['name']) {
$name = '';
} else {
$name = $prevName = $row['name'];
}
?>
<tr>
<td><?php echo htmlspecialchars($name); ?></td>
<td><?php echo htmlspecialchars($row['login']); ?></td>
<td><?php echo htmlspecialchars($row['evaluation']); ?></td>
</tr>
<?php endforeach; ?>
</table>
Het resultaat is: