Versuchen Sie, mysql_*
zu vermeiden Funktionen. Verwenden Sie mysqli_*
. Sie müssen sie nur zuerst gruppieren. Betrachten Sie dieses Beispiel:
<?php
$link = new mysqli('localhost', 'test', 'test', 'test');
$query = mysqli_query($link, 'SELECT * FROM author_master ORDER BY author_id');
$books = array();
while($row = $query->fetch_assoc()) {
$books[$row['author_id']][] = $row;
}
?>
<table border="0" cellpadding="10">
<thead>
<tr>
<th>Author ID</th>
<th>Author Book</th>
<th>Rating</th>
</tr>
</thead>
<tbody>
<?php foreach($books as $author_id => $values): ?>
<tr>
<td><?php echo $author_id; ?></td>
<td><?php foreach($values as $author_book) {echo $author_book['author_book'] . '<br/>';} ?></td>
<td><?php foreach($values as $author_book) {echo $author_book['rating'] . '<br/>';} ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>