John Davidson

javascript - How to display group data based on end date?

0 comments
Message:


I have a table like below:


How can i display the data based on task end date with new table. Meaning that, the full <div tag`` will repeat for each ending date and display the records on columns. For example-


                                        **Staff 1**

Date: 2020-11-14


Date: 2020-11-27


                                         **Staff 2**

Date: 2020-11-14


Thanking in anticipation.


<div>
<table class="table table-bordered">
<tr>
<th>ID</th>
<th>Task Name</th>
<th>Remarks</th>
<th>Start Date</th>
<th>End Date</th>
</tr>
<?php
$sql = "SELECT * FROM dl_fullremarks ";
$result = mysqli_query($conn, $sql);
foreach ($result as $row) {?>
<tr>
<td><?php echo $row['staff_id']; ?></td>
<td><?php echo $row['task_name']; ?></td>
<td><?php echo $row['task_remarks']; ?></td>
<td><?php echo $row['task_startdate']; ?></td>
<td><?php echo $row['task_enddate']; ?></td>
</tr>
<?php
}
?>
</table>
</div>


My Answer:
To display the data based on task end date with a new table for each ending date, you can use JavaScript to group the data by end date and create a new table for each unique end date. Here's an example of how you can achieve this:

html





This code will group the table data by end date and create a new table for each unique end date, displaying the records in columns. It will also display a heading for each staff member based on their ID. You can adjust the styling and layout as needed.

Rate this post

4 of 5 based on 2000 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us