I have a 7 check-boxes(monday,tuesday,wed,thur,friday,sat,sunday) and each of these tag i am having start and end time tag. Down below you can see the picture of the design

Now in database there is couple of entries like 1st id is having monday and bluh..bluh. You can see the picture of the database
<form id="checking" method="POST" >
<?php
$data=new User();
// in row it is array of the database details
$row=$data->Display('date');
$checkbox='';
$days = ["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
$out[]='<table>';
for($i = 1; $i <=7; $i++){
$out[]= '<tr>';
$out[]= '<td><input type="checkbox" name="events[]" value="'.$i.'" />'.$days[$i].'</td>';
$out[]= '<td><input type="text" name="start'.$i.'" value="'.$row[$i]['starttime'].'" />da</td>';
$out[]= '<td><input type="text" name="end'.$i.'" id="endTime'.$i.'" />End Time</td>';
$out[]= '</tr>';
}
$out[]='<table>';
echo join($out);
?>
<br/> <button id="sub" name="btnregister">Submit</button>
</form>

Now here is the trick- Fetch the details from the database and display it in input fields and if monday is having then it should checked that checkbox.
I really do not know what type of code i write and how i can print weekend name and should checked the checkbox if enteries is entered in database.