Buena pregunta, el cálculo de la amplitud de filas se realiza contando las facturas. Aquí está el código que se me ocurrió:
<?php
/**
* @author Truth
* @copyright 2011
*/
$dsn = "mysql:host=localhost;dbname=test";
$dbc = new PDO($dsn, 'root', 'pass');
$query = 'SELECT * FROM invoice';
$stmt = $dbc->prepare($query);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$result[$row['client_id']][] = $row['invoice_id'];
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Metas -->
<meta http-equiv="content-type" content="utf-8" />
<meta name="author" content="Truth" />
<title>Invoice Rowspan Example</title>
</head>
<body>
<table id="invoices" border="1">
<thead>
<th>Client</th>
<th>Invoices</th>
</thead>
<tbody>
<?php
foreach($result as $id => $invoices) {
echo '<tr>';
echo '<td rowspan='. count($invoices) . '>' . $id . '</td>';
$count = 0;
foreach ($invoices as $invoice) {
if ($count != 0) {
echo '<tr>';
}
echo "<td>$invoice</td>";
echo "</tr>";
$count++;
}
}
?>
</tbody>
</table>
</body>
</html>
Esto genera una tabla como usted requiere. Si hay algo que no entiendes, comenta y te explico