This is the output that i get based on the code below but this is the first page only, it contains more than 20 list of subjects but i show only 8 here.
This is my code in the Controller
public function showSubjectListFinalYear(){
$t1 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S1');
$t2 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S2');
$t3 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S3');
$t4 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S4');
$t5 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S5');
$t6 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S6');
$t7 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S7');
$t8 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S8');
$t9 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S9');
$t10 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S10');
$t11 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S11');
$t12 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S12');
$t13 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S13');
$t14 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S14');
$t15 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S15');
$t16 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S16');
$t17 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S17');
$t18 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S18');
$t19 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S19');
$t20 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S20');
$t21 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S21');
$t22 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S23_E1');
$t23 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S24_E1');
$t24 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S25_E2');
$t25 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S26_E2');
$t26 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S27_E2');
$t27 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S28_E2');
$t28 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S29_E2');
$t29 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S30_E3');
$t30 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S31_E3');
$t31 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S32_E3');
$t32 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S33_E3');
$t33 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S34_E4');
$t34 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S35_E4');
$t35 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S36_E4');
$t36 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S37_E4');
$t37 = DB::table('matrices')->where('total_subject_left','<',10)->sum('S22_E1');
return view ('admin.final_year_subject_list')->with(compact('t1','t2','t3','t4','t5','t6','t7','t8','t9','t10','t11','t12','t13','t14','t15','t16','t17','t18','t19','t20','t21',
't22','t23','t24','t25','t26','t27','t28','t29','t30','t31','t32','t33','t34','t35','t36','t37'));
}
This is my code in the view
<thead>
<tr>
<th>Subject name</th>
<th>No. of students</th>
</tr>
</thead>
<tbody>
@if($t1>0)
<tr class="gradeX">
<td>Teknologi dan Sistem Maklumat</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t2>0)
<tr class="gradeX">
<td>Struktur diskrit</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t3>0)
<tr class="gradeX">
<td>Teknik Pengaturcaraan 1</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t4>0)
<tr class="gradeX">
<td>Logik Digital</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t5>0)
<tr class="gradeX">
<td>Matematik Pengkomputeran</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t6>0)
<tr class="gradeX">
<td>Teknik Pengaturcaraan 2</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t7>0)
<tr class="gradeX">
<td>Komunikasi Rangkaian</td>
<td style="text-align:center"d></td>
</tr>
@endif
@if($t8>0)
<tr class="gradeX">
<td>Pengaturcaraan Web</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t9>0)
<tr class="gradeX">
<td>Pangkalan Data</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t10>0)
<tr class="gradeX">
<td>Struktur Data dan Algoritma</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t11>0)
<tr class="gradeX">
<td>Analisa dan Rekabentuk Sistem</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t12>0)
<tr class="gradeX">
<td>Organisasi Senibina Komputer</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t13>0)
<tr class="gradeX">
<td>Interaksi Komputer Manusia</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t14>0)
<tr class="gradeX">
<td>Kebarangkalian dan Analisa Data Statistik</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t15>0)
<tr class="gradeX">
<td>Pengaturcaraan Berorentasikan Objek</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t16>0)
<tr class="gradeX">
<td>Kejuruteraan Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t17>0)
<tr class="gradeX">
<td>Sistem Pengoperasian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t18>0)
<tr class="gradeX">
<td>Teori Sains Komputer</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t19>0)
<tr class="gradeX">
<td>Keushawanan Teknologi Maklumat dan Seminar</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t20>0)
<tr class="gradeX">
<td>Projek 1</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t21>0)
<tr class="gradeX">
<td>Projek 2</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t37>0)
<tr class="gradeX">
<td>Pengaturcaraan Pangkalan Data</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t22>0)
<tr class="gradeX">
<td>Kejuruteraan Keperluan dan Permodelan Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t23>0)
<tr class="gradeX">
<td>Pengurusan Projek Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t24>0)
<tr class="gradeX">
<td>Kepintaran Buatan</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t25>0)
<tr class="gradeX">
<td>Pembangunan Aplikasi</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t26>0)
<tr class="gradeX">
<td>Pengaturcaraan Internet</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t27>0)
<tr class="gradeX">
<td>Jaminan Kualiti Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t28>0)
<tr class="gradeX">
<td>Sistem Pakar Berasaskan Pengetahuan</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t29>0)
<tr class="gradeX">
<td>Rekabentuk dan Senibina Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t30>0)
<tr class="gradeX">
<td>Kepintaran Komputer</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t31>0)
<tr class="gradeX">
<td>Teknik Pengaturcaraan 3</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t32>0)
<tr class="gradeX">
<td>Topik Khas dalam Kejuruteraan Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t33>0)
<tr class="gradeX">
<td>Pembinaan Perisian</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t34>0)
<tr class="gradeX">
<td>Kejuruteraan Perisian Masa Nyata</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t35>0)
<tr class="gradeX">
<td>Teknologi Web</td>
<td style="text-align:center"></td>
</tr>
@endif
@if($t36>0)
<tr class="gradeX">
<td>Kejuruteraan Perisian Berorentasikan Ejen</td>
<td style="text-align:center"></td>
</tr>
@endif
</tbody>
My problem is I want to save all of the subject name and No. of students based on the table generated into a table named 'finalyear_subjects' while the data needed to generate this table came from table named 'matrices'. I'm not sure on how to do it and I hope someone can show me the way . Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire