Hi I have table wys_attendances(id,t_id, t_date,t_month_t_year,t_attend)
Iam trying to fetch one full month attendances from wys_attendance table like pivot table format. rows base teacher name and column base full month day (1/2/2015,2/2/2015....28/2/2015) i got this format output by using this code my controller $teacher = WysTeacher::all(); $dayCount = date('t', strtotime('01-'. $amonth . '-' . $ayear)); for($i = 1; $i <= $dayCount; $i++)
my view .blade.php
<tr class="tbl-head"> <td>Teacher Name</td> @for($i = 1; $i <= $dayCount; $i++) <td>{{$i}}</td> @endfor </tr> @foreach($teacher as $teachers) <tr>
<td>{{$teachers->tname}}</td> @endforeach </tr>
then iam try to display attendance(present() p/absend(a))below in column date and also corrseponding teachername by usinf this code
@foreach($attendance as $attendances)
@if($teachers->id == $attendances->t_auserid)
@if($attendances->t_attendance == 1)
<td><font color="green">p</font></td>
@elseif($attendances->t_attendance == 0)
<td><font color="red">a</font></td>
@endif
@endif
@endforeach
its work fine ,but one problem ,the problem is attendance marked at not corresponding date.
if1/2/2015 date not in database and 2.2/2015 is in database all present(p). but display in view page column 1/2/2015 below marked p value and 2/2/2015 below marked next day attendance .
how to check month date and database value is correct??and display attendance at correcponding date below.
Aucun commentaire:
Enregistrer un commentaire