My code is just query a database and output to a HTML table:
<?php
include("incl\dbcon.php");
$sql = "SELECT * FROM attendanceRecord";
$result = $db_con->query($sql);
echo "<table>
<tr>
<th>Date</th>
<th>Building Name</th>
<th>Room Name</th>
<th>Student</th>
<th>Time</th>
</tr>";
while($row_result = $result->fetch_assoc()){
echo "<tr>";
echo "<td>" . $row_result['rDate'] . "</td>";
echo "<td>" . $row_result['rBuildingName'] . "</td>";
echo "<td>" . $row_result['rRoomName'] . "</td>";
echo "<td>" . $row_result['rStudent'] . "</td>";
echo "<td>" . $row_result['rTime'] . "</td>";
echo "</tr>";
}
$db_con->close();
echo "</table>";
?>
the result is like:
Date Building Name Room Name Student Time
2018-07-12 Building A 1A Sam 08:32:33
2018-07-12 Building A 1A David 08:54:21
2018-07-12 Building A 1A Dragon 08:50:10
2018-07-12 Building A 1B John 08:43:11
2018-07-12 Building A 1B Coco 08:51:39
2018-07-12 Building B 3A Mary 08:21:23
2018-07-12 Building B 3A Martin 08:46:57
2018-07-12 Building B 4B Ray 08:26:47
How can I don't show or empty the duplicate fields in a row and make the table looks like below?
Date Building Name Room Name Student Time
2018-07-12 Building A 1A Sam 08:32:33
David 08:54:21
Dragon 08:50:10
1B John 08:43:11
Coco 08:51:39
Building B 3A Mary 08:21:23
Martin 08:46:57
4B Ray 08:26:47
Where should i approach? from sql query(don't know is there a function to empty or NULL duplicate fields while query) or php array(print NULL if duplicate then move the pointer?), please help, thanks in advance!