the problem is i want to foreach 2 query inside one table .. but it doesn't work perfectly ..
first query reslut in array is :
Array ( [0] => Array ( [KODE_BRG] => YD-027 [NAMA_BRG] => CIMORY YD STRAW 70 ML BANDED 4 [OOS] => 17 [Available] => 2 [Total_Kunjungan] => 19 [Persen_OOS] => 89 ) 1 => Array ( [KODE_BRG] => YD-069 [NAMA_BRG] => CIMORY YD STRAWBERY MANGGO LF [OOS] => 38 [Available] => 5 [Total_Kunjungan] => 43 [Persen_OOS] => 88 ) 2 => Array ( [KODE_BRG] => YD-010 [NAMA_BRG] => CIMORY YD MIXED BERRIES 250 ML [OOS] => 54 [Available] => 8 [Total_Kunjungan] => 62 [Persen_OOS] => 87 ) [3] => Array ( [KODE_BRG] => YD-072 [NAMA_BRG] => CIMORY YD BANANA LF [OOS] => 37 [Available] => 6 [Total_Kunjungan] => 43 [Persen_OOS] => 86 ) [4] => Array ( [KODE_BRG] => YD-015 [NAMA_BRG] => CIMORY YD BLUEBERRY 250 ML [OOS] => 53 [Available] => 9 [Total_Kunjungan] => 62 [Persen_OOS] => 85 ) [5] => Array ( [KODE_BRG] => YD-028 [NAMA_BRG] => CIMORY YD BLUEBERRY 70 ML BND4 [OOS] => 16 [Available] => 3 [Total_Kunjungan] => 19 [Persen_OOS] => 84 ) [6] => Array ( [KODE_BRG] => YD-029 [NAMA_BRG] => CIMORY YD MIXED 70 ML BANDED 4 [OOS] => 16 [Available] => 3 [Total_Kunjungan] => 19 [Persen_OOS] => 84 ) [7] => Array ( [KODE_BRG] => YD-044 [NAMA_BRG] => YOLITE C+100 ORANGE [OOS] => 16 [Available] => 3 [Total_Kunjungan] => 19 [Persen_OOS] => 84 ) [8] => Array ( [KODE_BRG] => YD-045 [NAMA_BRG] => YOLITE C+100 ORIGINAL [OOS] => 16 [Available] => 3 [Total_Kunjungan] => 19 [Persen_OOS] => 84 ) [9] => Array ( [KODE_BRG] => YD-008 [NAMA_BRG] => CIMORY YD PLAIN 250 ML [OOS] => 51 [Available] => 11 [Total_Kunjungan] => 62 [Persen_OOS] => 82 ) )
the second query in array is :
Array ( [0] => Array ( [KODE_BRG] => YD-004 [Qty] => 379 ) 1 => Array ( [KODE_BRG] => YD-005 [Qty] => 347 ) 2 => Array ( [KODE_BRG] => YD-002 [Qty] => 240 ) [3] => Array ( [KODE_BRG] => YD-006 [Qty] => 211 ) [4] => Array ( [KODE_BRG] => YD-072 [Qty] => 127 ) [5] => Array ( [KODE_BRG] => YD-008 [Qty] => 126 ) [6] => Array ( [KODE_BRG] => YD-069 [Qty] => 121 ) [7] => Array ( [KODE_BRG] => YD-015 [Qty] => 101 ) [8] => Array ( [KODE_BRG] => YD-010 [Qty] => 82 ) [9] => Array ( [KODE_BRG] => YD-001 [Qty] => 72 ) )
there is 10 result inside both of query ..
and this is what i want to achieve:
| lOOS | --- | SBQ | ---- |
|---|---|---|---|
| produk name from Query1 | precentage Qty product from Query1 | Product Code from Query2 | Qty from Query2 |
| ..... | ........ | ........ | .... |
| till 10th | till 10th | till 10th | till 10th |
and i tried many ways to achieve that but i didnt find the correct way to achieve it .
this is my the last try :
<table style="width: 100%" >
<thead>
<tr style="border-bottom: 1px solid;">
<th colspan=2><center>Out Of Stock</center></th>
<th colspan=2><center>Sales By Qty</center></th>
</tr>
</thead>
<tbody>
<?php foreach ($OOS->result_array() as $key => $val1){?>
<?php foreach ($SBQ->result_array() as $Kunci =>$val2) {?>
<tr>
<td width="200">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:33%"><?php echo $val1['NAMA_BRG'] ?>
</div>
</td>
<td width="50"><?php echo $val1['Persen_OOS'] ?></td>
<td><div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:33%"><?php echo $val2['KODE_BRG'] ?>
</div>
</td>
<td width="50"><?php echo $val2['Qty'] ?></td>
</tr>
<?php }?>
<?php }?>
</tbody>
</table>
but the result it looping every product 10 time and then moved to the second product .. here is the result of the last try :
and here is example by image of what i want to achieve :
can someone tell me where is my wrong code and help me acheive that and made my day
source https://stackoverflow.com/questions/67714057/forach-2-query-in-one-table-side-by-side


Comments
Post a Comment