I have created a table from a SQL query and displayed it in the same order as they appear in the table. (Table A in image).
This is working okay.
However it would be great if the data could be clubbed under the member category. As in Table B in image.
SQL Query ...
$row = mysqli_num_rows($sql);
if($row > 0) {
while ($result = mysqli_fetch_assoc($sql)){
$category[] = trim($result['category']);
$name[] = trim($result['f_name']).' '.trim($result['l_name']);
$memid[] = trim($result1['memid']);
$addr[] = trim($result['addr']);
$phone[] = trim($result['phone']);
}
} ?>
<table>
<tr>
<th>Category</th>
<th>Mem ID</th>
<th>Name</th>
<th>Address</th>
<th>Phone</th>
</tr>
<?php
if ($row>0) {
for ($i=0; $i<=$row-1; $i++){ ?>
<tr>
<td><?php echo $category[$i]; ?></td>
<td><?php echo $memid[$i]; ?></td>
<td><?php echo $name[$i]; ?> </td>
<td><?php echo $addr[$i]; ?> </td>
<td><?php echo $phone[$i]; ?> </td>
</tr>
<?php }
} ?>
</table>
