sql - How to check if all days of the month are in the database -


this table wys_attendence:

id   studid  adate  amonth  ayear  acls_id  attendence       1    28      02     07      2015   10       1      2    31      02     07      2015   10       0   4    32      02     07      2015   10       1    5    28      13     07      2015   10       0  6    31      13     07      2015   10       1    7    32      13     07      2015   10       1    9    28      14     07      2015   10       1    10   31      14     07      2015   10       1    11   32      14     07      2015   10       1    13   28      15     07      2015   10       1    14   31      15     07      2015   10       0    15   32      15     07      2015   10       1    17   28      16     07      2015   10       0    18   31      16     07      2015   10       1    19   32      16     07      2015   10       1    21   28      17     07      2015   10       1    22   31      17     07      2015   10       1    23   32      17     07      2015   10       0    24   28      20     08      2015   10       1    25   31      20     08      2015   10       1    26   32      20     08      2015   10       0   

i want check if every day of specific year , month in table, , display results in pivot table.

i using code:

$daycount = date('t', strtotime('01-'. $amonth . '-' . $ayear)); $days = []; for($i = 1; $i <= $daycount; $i++) { $days[] = $i; } 

to display dates of selected month , year.

i using code controller:

for($i = 1; $i <= $daycount; $i++) {   $days[] = sprintf('%02d/%02d/%04d', $i, $amonth, $ayear);              $attendance = db::table('wys_teacherattendances')      ->where('t_amonth', $amonth)     ->where('t_ayear', $ayear)     ->get();            } 

the output incorrect. get:

studid 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  17.......... 31  28    0 1 1 1 0 1  31    1 1 1 1 1 1  32    0 1 1 1 1 0 

but want this:

studid 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17.......... 31  28    x 0 x x x x x x x x x x x  1  1  1  0  1.....x x x..x  31    x 1 x x x x x x x x x x x  1  1  1  1  1.....x x x..x  32    x 0 x x x x x x x x x x x  1  1  1  1  0.....x x x..x 

how can modify query achieve above result check if days of selected month , year in database or not? if studid doesn't have specific day, want display x in corresponding column, otherwise want display value of attendance.

and how change view.blade.php page fetch database table?

this view.blade.php code:

@for($i = 1; $i <= $daycount; $i++)     <td>{{$i}}</td> @endfor </tr> @foreach($stud $studs)     <tr>          <td>{{$studs->sname}}</td>     @foreach($attendance $attendances)         @if($studs->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     </tr> @endforeach   </tr> @endforeach 


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -