Laravel 4 如何使用laravel以正确的顺序显示2个月的值
这是我的桌面wys_出席:Laravel 4 如何使用laravel以正确的顺序显示2个月的值,laravel-4,Laravel 4,这是我的桌面wys_出席: 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 30 07
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 30 07 2015 10 0
6 31 30 07 2015 10 1
7 32 30 07 2015 10 1
9 28 31 07 2015 10 1
10 31 31 07 2015 10 1
11 32 31 07 2015 10 1
13 28 06 08 2015 10 1
14 31 06 08 2015 10 0
15 32 06 08 2015 10 1
17 28 07 08 2015 10 0
18 31 07 08 2015 10 1
19 32 07 08 2015 10 1
21 28 08 08 2015 10 1
22 31 08 08 2015 10 1
23 32 08 08 2015 10 0
24 28 12 08 2015 10 1
25 31 12 08 2015 10 1
26 32 12 08 2015 10 0
我想检查表中是否有t_adates之间的值,并显示t_adates之间的值
如果我是,请选择1/07/2015至31/08/0215
我得到的输出不正确。这就是我得到的:
studid 2/07/2015 06/08/2015 07/08/2015 08/08/2015 30/07/205 31/07/2015
28 1 1 0 1 0 1
31 0 0 1 1 1 1
32 1 1 1 0 1 1
不显示顺序不正确的值
但我希望它是这样的:
studid 2/07/2015 30/07/205 31/07/2015 06/08/2015 07/08/2015 08/08/2015
28 1 0 1 1 0 1
31 0 1 1 0 1 1
32 1 1 1 1 1 0
我的控制器代码在这里
`$startdate_exploded = explode("/",Input::get('curdate'));
$enddate_exploded = explode("/",Input::get('enddate'));
$attendence_tbl = WysAttendancename::where('cls_id',$id)->first();
$wys_attendence_table = $attendence_tbl->attendance_name;
$attendance = DB::table($wys_attendence_table)
->whereBetween('adate', array($startdate_exploded[0], $enddate_exploded[0]))
->whereBetween('amonth', array($startdate_exploded[1], $enddate_exploded[1]))
->whereBetween('ayear', array($startdate_exploded[2], $enddate_exploded[2]))
->groupBy('adate')
->get();
$stud_attend = DB::table($wys_attendence_table)
->whereBetween('adate', array($startdate_exploded[0], $enddate_exploded[0]))
->whereBetween('amonth', array($startdate_exploded[1], $enddate_exploded[1]))
->whereBetween('ayear', array($startdate_exploded[2], $enddate_exploded[2]))
->get();`
我的view.blade.php是
`<td>Student Name</td>
@foreach($attendance as $attendances)
<td><font size="-1">{{$attendances->adate}}-{{$attendances->amonth}}-{{$attendances->ayear}}</font></td>
@endforeach
</tr>
@foreach($students as $student)
@if($student->studcls == $id)
<tr>
<td>{{$student->studname}}</td>
@foreach($stud_attend as $stud_attends)
@if($student->id == $stud_attends->studid)
@if($stud_attends->attendence == 1)
<td><font color="green" size="3">p</font></td>
@elseif($stud_attends->attendence == 0)
<td><font color="red" size="3">a</font></td>
@endif
@endif
@endforeach
</tr>
@endif
@endforeach`
学生姓名
@foreach($出席人数)
{{$attents->adate}-{{$attents->amonth}-{{$attents->ayear}
@endforeach
@foreach($student作为$student)
@如果($student->studcls==$id)
{{$student->studname}
@foreach($stud_作为$stud_出席)
@如果($student->id==$stud\u attents->studid)
@如果($stud\u attends->attendence==1)
P
@elseif($stud\u attents->attentence==0)
A.
@恩迪夫
@恩迪夫
@endforeach
@恩迪夫
@endforeach`
如何修改查询以获得上述结果,并检查所有日期(2015年7月1日至2015年8月31日)是否在数据库中?如果在数据库中,则日期仅显示一次,并在数据库中显示所有详细信息?如果要按日期对记录进行分组,请使用groupBy(),如中所述
如果要按日期对记录进行分组,请使用groupBy(),如中所述
$attendance = DB::table('wys_teacherattendances')
->where('t_amonth', $amonth)
->where('t_ayear',$ayear)
->groupBy('t_adate')
->get();